aboutsummaryrefslogtreecommitdiffstats
path: root/config/herbstluftwm/panel.sh
diff options
context:
space:
mode:
Diffstat (limited to 'config/herbstluftwm/panel.sh')
-rwxr-xr-xconfig/herbstluftwm/panel.sh160
1 files changed, 0 insertions, 160 deletions
diff --git a/config/herbstluftwm/panel.sh b/config/herbstluftwm/panel.sh
deleted file mode 100755
index 763c668..0000000
--- a/config/herbstluftwm/panel.sh
+++ /dev/null
@@ -1,160 +0,0 @@
1#!/bin/bash
2
3hc() {
4 "${herbstclient_command[@]:-herbstclient}" "$@" ;
5}
6
7dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
8source "$dir/theme.sh"
9source "$dir/panel_indicators.sh"
10
11monitor=${1:-0}
12
13geometry=( $(herbstclient monitor_rect "$monitor") )
14if [ -z "$geometry" ] ;then
15 echo "Invalid monitor $monitor"
16 exit 1
17fi
18# geometry has the format W H X Y
19x=$(echo "${geometry[0]} + $window_p" | bc)
20y=$(echo "${geometry[1]} + $window_p" | bc)
21panel_width=$(echo "${geometry[2]} - (2 * $window_p)" | bc)
22bar_opts="-g ${panel_width}x${panel_h}+${x}+${y} -f $font,$font_sec -u 2 -B $acolor_bg -F $acolor_fg"
23
24hc pad $monitor $(echo "$panel_h + $window_p" | bc)
25
26if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then
27 # mawk needs "-W interactive" to line-buffer stdout correctly
28 # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504
29 uniq_linebuffered() {
30 awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@"
31 }
32else
33 # other awk versions (e.g. gawk) issue a warning with "-W interactive", so
34 # we don't want to use it there.
35 uniq_linebuffered() {
36 awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
37 }
38fi
39
40{
41 ### Event generator ###
42 # <eventname>\t<data> [...]
43 # e.g.
44 # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
45 while true ; do
46 music
47 volume
48 network
49 battery
50 clock
51 sleep 1 || break
52 done > >(uniq_linebuffered) &
53 childpid=$!
54 hc --idle
55 kill $childpid
56} 2> /dev/null | {
57
58 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
59 visible=true
60 date=""
61 volume=""
62 battery=""
63 net=""
64 windowtitle=""
65 while true ; do
66 separator="%{F$acolor_accent}|%{F-}"
67 # draw tags
68 for i in "${tags[@]}" ; do
69 case ${i:0:1} in
70 '#')
71 echo -n "%{U$acolor_accent+u}%{F$acolor_fg}"
72 ;;
73 '+')
74 echo -n "%{U$acolor_fg+u}%{F$acolor_fg}"
75 ;;
76 ':')
77 echo -n "%{F$acolor_fg}"
78 ;;
79 '!')
80 echo -n "%{B$acolor_accent}%{U$acolor_accent+u}%{F$acolor_bg}"
81 ;;
82 *)
83 echo -n "%{F$acolor_fg}"
84 ;;
85 esac
86 echo -n "%{A:tag,${i:1}:} ${i:1} %{A}%{F-}%{U-u}%{B-}"
87 done
88 echo -n "$separator%{F-}%{B-} "
89 echo -n "${windowtitle//^/^^}"
90
91 #Right part of panel
92 right="$music$volume$net$battery$date "
93 echo -n "%{r}$right"
94
95 #DO NOT REMOVE THIS ECHO
96 echo
97
98 # wait for next event
99 IFS=$'\t' read -ra cmd || break
100 case "${cmd[0]}" in
101 tag*)
102 #echo "resetting tags" >&2
103 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
104 ;;
105 music)
106 music="${cmd[@]:1}"
107 if [ $music == "off" ] ; then
108 music=""
109 else
110 music="$music $separator%{B-} "
111 fi
112 ;;
113 volume)
114 volume="${cmd[@]:1}"
115 if [ $volume == "off" ] ; then
116 volume=""
117 else
118 volume="$volume $separator%{B-} "
119 fi
120 ;;
121 net)
122 net="${cmd[@]:1}"
123 if [ $net = "off" ] ; then
124 net=""
125 else
126 net="$net $separator%{B-} "
127 fi
128 ;;
129 battery)
130 battery="${cmd[@]:1}"
131 if [ $battery == "off" ] ; then
132 battery=""
133 else
134 battery="$battery $separator%{B-} "
135 fi
136 ;;
137 date)
138 #echo "resetting date" >&2
139 date="${cmd[@]:1}"
140 ;;
141 focus_changed|window_title_changed)
142 windowtitle="${cmd[@]:2}"
143 ;;
144 esac
145 done
146} 2> /dev/null | bar $bar_opts | {
147 #Handle clickable areas
148 while read line; do
149 IFS=',' read -a c <<< $(echo $line)
150 case "${c[0]}" in
151 tag)
152 herbstclient use "${c[1]}"
153 echo "herbstclient use \"${c[1]}\""
154 ;;
155 *)
156 echo "${c[0]}: not valid command"
157 ;;
158 esac
159 done
160}