-
Notifications
You must be signed in to change notification settings - Fork 1
/
max
executable file
·82 lines (71 loc) · 2.25 KB
/
max
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
78
79
80
81
82
#!/bin/sh
# rockin' script by z3bra
# includes fullscreen, max h, and max v
# thank you!
# modified by dkeg
# now includes maximize (like cwm), slight gaps all around
# also includes a fullscreen with panel gap
#. $HOME/bin/barconf
usage() {
echo "usage: $(basename $0) [-hvmpf] wid" >&2
exit 1
}
while getopts hvmpf OPT; do
case $OPT in
h) MAX=horz ;;
v) MAX=vert ;;
m) MAX=gmax ;;
p) MAX=fullp ;;
f) MAX=full ;;
*) usage ;;
esac
done
shift $((OPTIND -1))
test -n "$1" && WID=$1 || usage
MAX=${MAX:-full}
EXPANDIR=/tmp/.expan.d
#PAD=$bar3h
PAD=105
#PAD=85
PAD2=18
tg=12
BW=$(wattr b $WID)
SW=$(( $(wattr w `lsw -r`) - 2*$BW))
SH=$(( $(wattr h `lsw -r`) - 2*$BW))
SHP=$(( $(wattr h `lsw -r`) - 2*$BW - $PAD2))
#SWM=$(( $(wattr w `lsw -r`) - 8*$BW - 8*$PAD))
#SHM=$(( $(wattr h `lsw -r`) - 8*$BW - 8*$PAD))
SWM=$(( $(wattr w `lsw -r`) - 2*$BW - 2*$PAD))
SHM=$(( $(wattr h `lsw -r`) - 2*$BW - 2*$PAD))
test -d $EXPANDIR || mkdir -p $EXPANDIR
is_maxed() {
case $MAX in
vert) test $(wattr h $WID) -eq $SHM && return 0 ;;
horz) test $(wattr w $WID) -eq $SWM && return 0 ;;
#vert) test $(wattr h $WID) -eq $SH && return 0 ;;
#horz) test $(wattr w $WID) -eq $SW && return 0 ;;
gmax) test "$(wattr wh $WID)" = "$SWM $SHM" && return 0 ;;
fullp) test "$(wattr wh $WID)" = "$SW $SHP" && return 0 ;;
full) test "$(wattr wh $WID)" = "$SW $SH" && return 0 ;;
esac
return 1
}
expand_win() {
wattr xywhi $WID > $EXPANDIR/$WID
case $MAX in
vert) GEOMETRY=$(printf '%d '$PAD' %d %d' $(wattr xw $WID) "$SHM") ;;
#vert) GEOMETRY=$(printf '%d 0 %d %d' $(wattr xw $WID) "$SH") ;;
#horz) GEOMETRY=$(printf '0 %d %d %d' $(wattr y $WID) "$SW" $(wattr h $WID)) ;;
horz) GEOMETRY=$(printf ''$PAD' %d %d %d' $(wattr y $WID) "$SWM" $(wattr h $WID)) ;;
gmax) GEOMETRY=$(printf ''$PAD' '$PAD' %d %d' "$SWM" "$SHM") ;;
fullp) GEOMETRY=$(printf '0 '$PAD2' %d %d' "$SW" "$SHP") ;;
full) GEOMETRY=$(printf '0 0 %d %d' "$SW" "$SH") ;;
esac
wtp ${GEOMETRY} ${WID}
}
collapse_win() {
test -f $EXPANDIR/$WID || return
wtp $(grep $WID $EXPANDIR/$WID)
rm $EXPANDIR/$WID
}
is_maxed && collapse_win || expand_win ;