-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmgfw
executable file
·77 lines (63 loc) · 1.21 KB
/
mgfw
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
74
75
76
77
#!/bin/sh
#
# mgfw - manage groups for windows
# (c) arcetera 2015 - wtfpl
#
. ~/.config/wmrc/config
usage() {
echo "$(basename $0) [-adsth <gid>]"
}
addtgrp() {
:> $GRPROOT/$2/$1
showgrp $2
}
removefgrp() {
[ "$2" = "all" ] \
&& rm -f $GRPROOT/*/$1 \
|| rm -f $GRPROOT/$2/$1
}
findgrp() {
file=$(find $GRPROOT -name "$1")
[ -n "$file" ] && basename $(dirname $file)
}
showgrp() {
for file in $GRPROOT/$1/*; do
wid=$(basename $file)
mapw -m $wid
done
}
hidegrp() {
for file in $GRPROOT/$1/*; do
wid=$(basename $file)
mapw -u $wid
done
}
togggrp() {
wid=$(ls -1 $GRPROOT/$1 | sed 1q)
[ -z "$wid" ] && return
wattr m $wid \
&& hidegrp $1 \
|| showgrp $1
}
cgrps() {
for gid in $(seq 1 $GRPNUM ); do
[ -d $GRPROOT/$gid ] || mkdir -p $GRPROOT/$gid
done
for file in $(find $GRPROOT -type f); do
wid=$(basename $file)
wattr $wid || rm -f $file
done
}
cgrps
while getopts ":a:wd:gm:t:h:" opt; do
case $opt in
a) addtgrp $(pfw) $OPTARG ;;
d) removefgrp $(pfw) $OPTARG ;;
g) findgrp $(pfw) ;;
s) showgrp $OPTARG ;;
t) togggrp $OPTARG ;;
h) hidegrp $OPTARG ;;
*) usage && exit 0;;
esac
done
[ $# -eq 0 ] && tree --noreport $GRPROOT