forked from lwilletts/fyre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wclass.sh
executable file
·66 lines (62 loc) · 1.53 KB
/
wclass.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/sh
#
# wildefyr - 2015 (c) wtfpl
# checks a windows class
usage() {
printf '%s\n' "usage: $(basename $0) <command> (wid|lswArgs)"
exit 1
}
case $2 in
u|-u|unlisted) lswArgs="-u" ;;
o|-o|override) lswArgs="-o" ;;
a|-a|all) lswArgs="-a" ;;
esac
case $1 in
n|name)
case $2 in
0x*) xprop -id $2 WM_CLASS | cut -d\" -f 2 ;;
*) usage ;;
esac
;;
c|class)
case $2 in
0x*) xprop -id $2 WM_CLASS | cut -d\" -f 4 ;;
*) usage ;;
esac
;;
p|process)
case $2 in
0x*) xprop -id $2 _NET_WM_PID | cut -d\ -f 3 ;;
*) usage ;;
esac
;;
na|nameAll)
for i in $(seq $(lsw $lswArgs | wc -l)); do
wid=$(lsw $lswArgs | sed "$i!d")
printf '%s\n' "$wid $(wclass.sh c $wid)"
done
;;
ca|classAll)
for i in $(seq $(lsw $lswArgs | wc -l)); do
wid=$(lsw $lswArgs | sed "$i!d")
printf '%s\n' "$wid $(wclass.sh m $wid)"
done
;;
pa|processAll)
for i in $(seq $(lsw $lswArgs | wc -l)); do
wid=$(lsw $lswArgs | sed "$i!d")
printf '%s\n' "$wid $(wclass.sh p $wid)"
done
;;
a|all)
$(basename $0) na $lswArgs
$(basename $0) ca $lswArgs
for i in $(seq $(lsw $lswArgs | wc -l)); do
wid=$(lsw $lswArgs | sed "$i!d")
printf '%s\n' "$wid $(wname $wid)"
done
;;
*)
usage
;;
esac