summaryrefslogtreecommitdiff
path: root/dswitcher
blob: 981273351ecd37791d29f0d311e4b7be792c1052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env bash

# Date format, for use as the prompt.
date=$(date +"%Y.%m.%d..%H.%M")

# dmenu cannot display more than 30 lines, to avoid screen clutter. Only
# relevant if you have more than 30 windows open.
height=$(wmctrl -l | wc -l)
if [[ $height -gt 30 ]]
	then heightfit=30
	else heightfit=$height
fi

num=$(wmctrl -l \
    | sed 's/  / /' \
    | cut -d " " -f 4- \
    | nl --number-width=2 --number-format=rn -s "| " \
    | dmenu -i -p "$date" -l $heightfit \
    | cut -d '|' -f -1
)
[[ -z "$num" ]] && exit
wmctrl -l \
    | sed -n "$num p" \
    | cut -c -10 \
    | xargs wmctrl -i -a