blob: b7cf5e6d3e985efe61fe75fa80d3139b63d4414e (
plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#!/usr/bin/env bash
hc() {
"${herbstclient_command[@]:-herbstclient}" "$@"
}
monitor_bound() {
echo "$1" | cut -d' ' -f2
}
hlwm_id() {
while read -r bound; do
hc list_monitors | grep "$bound" | sed -e 's/:.*$//g'
done <<< "$(monitor_bound "$1")"
}
this_monitor=$(polybar -m | grep "$MONITOR")
monitor=$(hlwm_id "$this_monitor")
get_layout() {
currenttag=$(hc tag_status | tr '\t' '\n' | sed -n 's/#//p')
focusedtaglayout=$(hc layout "$currenttag" @ | awk '{print $2}' | sed 's/://')
case "$focusedtaglayout" in
vertical)
echo "V" ;;
horizontal)
echo "H" ;;
max)
echo "M" ;;
grid)
echo "G" ;;
esac
}
layout=$(get_layout)
herbstclient --idle "(tag_*|focus_changed|window_title_changed)" 2>/dev/null | {
while true; do
# Read tags into $tags array
IFS=$'\t' read -ra tags <<< "$(hc tag_status "$monitor")"
{
# Read the prefix from each tag
for i in "${tags[@]}" ; do
case ${i:1} in
'hidden')
;&
'scratchpad')
continue
;;
esac
case ${i:0:1} in
'#')
echo -n "%{B#9fbc00}%{F#101010}"
# Tag in focus on this monitor
;;
'%')
echo -n "%{B#9ca668}%{F#141414}"
# Tag in focus on other monitor
;;
'+')
echo -n "%{B#9ca668}%{F#141414}"
# tag viewed on this monitor
;;
'-')
echo -n "%{B#9ca668}%{F#141414}"
# Tag viewed on other monitor
;;
':')
echo -n "%{B#222}%{F#ffffff}"
# Tag is not empty
;;
'!')
echo -n "%{B#ff0675}%{F#141414}"
# Tag contains urgent window
;;
*)
echo -n "%{B#222}%{F#7a7a7a}"
;;
esac
echo "%{A1:herbstclient use ${i:1}:} ${i:1} %{A -u -o F- B-}"
done
echo "%{F-}%{B-}"
echo "| [$layout]"
} | tr -d "\n"
echo
IFS=$'\t' read -ra cmd || break
case "${cmd[0]}" in
focus_changed|window_title_changed|layout_changed)
layout=$(get_layout)
esac
# wait for next event from herbstclient --idle
# read -r || break
done
} 2>/dev/null
|