blob: 4a4250068a41dce24063e170394534bb43a37eba (
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
|
#!/usr/bin/env bash
# Multi monitor support. Needs MONITOR environment variable to be set for each instance of polybar
# If MONITOR environment variable is not set this will default to monitor 0
# Check https://github.com/polybar/polybar/issues/763
MON_IDX="0"
mapfile -t MONITOR_LIST < <(polybar --list-monitors | cut -d":" -f1)
for (( i=0; i<$((${#MONITOR_LIST[@]})); i++ )); do
[[ ${MONITOR_LIST[${i}]} == "$MONITOR" ]] && MON_IDX="$i"
done;
herbstclient --idle "tag_*" 2>/dev/null | {
while true; do
# Read tags into $tags as array
IFS=$'\t' read -ra tags <<< "$(herbstclient tag_status "${MON_IDX}")"
{
for i in "${tags[@]}" ; do
name=${i#?}
# Read the prefix from each tag and render them according to that prefix
case ${i:0:1} in
'.')
# the tag is empty
printf "%%{F#707880}"
;;
':')
# the tag is not empty
printf "%%{F#C5C8C6}"
;;
'+')
# the tag is viewed on the specified MONITOR, but this monitor is not focused.
printf "%%{F#cccccc}"
;;
'#')
# the tag is viewed on the specified MONITOR and it is focused.
printf "%%{R}"
;;
'-')
# the tag is viewed on a different MONITOR, but this monitor is not focused.
# TODO Add your formatting tags
;;
'%')
# the tag is viewed on a different MONITOR and it is focused.
# TODO Add your formatting tags
;;
'!')
# the tag contains an urgent window
printf "%%{B#CC6666}"
;;
esac
# focus the monitor of the current bar before switching tags
echo "%{A1:herbstclient focus_monitor ${MON_IDX}; herbstclient use ${i:1}:} ${i:1} %{A -u -o F- B-}"
done
# reset foreground and background color to default
echo "%{F-}%{B-}"
} | tr -d "\n"
echo
# wait for next event from herbstclient --idle
read -r || break
done
} 2>/dev/null
|