-
Notifications
You must be signed in to change notification settings - Fork 1
/
wclass
executable file
·73 lines (70 loc) · 1.42 KB
/
wclass
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
67
68
69
70
71
72
73
#!/bin/sh
#
# winclass - checks window class
# (c) ix && wildefyr 2016
#
usage() {
echo "usage: $(basename $0) <command> <wid|unlisted>"
exit 1
}
case $2 in
-u) lsw_args="-u" ;;
-o) lsw_args="-o" ;;
-a) lsw_args="-a" ;;
esac
case $1 in
-c)
case $2 in
0x*) xprop -id $2 WM_CLASS | cut -d\" -f 2 ;;
*) usage ;;
esac
;;
-m)
case $2 in
0x*) xprop -id $2 WM_CLASS | cut -d\" -f 4 ;;
*) usage ;;
esac
;;
-p)
case $2 in
0x*) xprop -id $2 _NET_WM_PID | cut -d\ -f 3 ;;
*) usage ;;
esac
;;
-ca)
for i in $(seq $(lsw $lsw_args | wc -l)); do
wid=$(lsw $lsw_args | sed "$i!d")
echo "$wid $($(basename $0) -c $wid)"
done
;;
-ma)
for i in $(seq $(lsw $lsw_args | wc -l)); do
wid=$(lsw $lsw_args | sed "$i!d")
echo "$wid $($(basename $0) -m $wid)"
done
;;
-pa)
for i in $(seq $(lsw $lsw_args | wc -l)); do
wid=$(lsw $lsw_args | sed "$i!d")
printf '%s\n' "$wid $($(basename $0) -p $wid)"
done
;;
--name)
for i in $(seq $(lsw $lsw_args | wc -l)); do
wid=$(lsw $lsw_args | sed "$i!d")
echo "$wid $($(basename $0) -m $wid)"
done
;;
--wname)
for i in $(seq $(lsw $lsw_args | wc -l)); do
wid=$(lsw $lsw_args | sed "$i!d")
echo "$wid $(wname $wid)"
done
;;
-a)
$(basename $0) -ca $lsw_args
$(basename $0) -ma $lsw_args
$(basename $0) --name $lsw_args
;;
*) usage ;;
esac