-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsidebar_2.sh
executable file
·70 lines (59 loc) · 1.33 KB
/
sidebar_2.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
67
68
69
70
#!/bin/bash
tag="${1:-sidebar}"
main_mon="${2:-0}"
monitor=sidebar
hc() {
herbstclient "$@";
}
show() {
mrect=( $(hc monitor_rect -p ${cur_mon} ) )
# mrect
# 0: x padding
# 1: y padding
# 2: width
# 3: heigth
termwidth=$((${mrect[2]}*3/10))
termheight=${mrect[3]}
# rect
# 0: width
# 1: height
# 2: x padding
# 3: y padding
side_rect=(
$termwidth
$termheight
$((${mrect[2]}-$termwidth))
${mrect[1]}
)
main_rect=(
$((${mrect[2]}-$termwidth))
${mrect[3]}
${mrect[0]}
${mrect[1]}
)
hc add "$tag"
echo $(printf "%dx%d%+d%+d" "${side_rect[@]}")
if hc add_monitor $(printf "%dx%d%+d%+d" "${side_rect[@]}") \
"$tag" $monitor 2> /dev/null ; then
local geom=$(printf "%dx%d%+d%+d" "${main_rect[@]}")
hc move_monitor "$main_mon" $geom
fi
local geom=$(printf "%dx%d%+d%+d" "${side_rect[@]}")
hc move_monitor "$monitor" $geom
}
hide() {
mrect=( $(hc monitor_rect -p ${cur_mon} ) )
srect=( $(hc monitor_rect -p ${monitor} ) )
termwidth=${srect[2]}
termheight=${srect[3]}
main_rect=(
$((${mrect[2]}+$termwidth))
${mrect[3]}
${mrect[0]}
${mrect[1]}
)
local geom=$(printf "%dx%d%+d%+d" "${main_rect[@]}")
hc move_monitor "$main_mon" $geom
hc remove_monitor "$monitor"
}
hide