aboutsummaryrefslogtreecommitdiffstats
path: root/.config
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2014-05-14 07:24:29 +0200
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2014-05-14 07:24:29 +0200
commit8f4a4d47cbe50f24d5d87a326e01ec3a4360714b (patch)
tree4f9040c5e5564d5cec2e40b867c4eb51b7e05c74 /.config
parentb5cd01ab7232b660dcf272b4c22c3879a1d84d87 (diff)
downloaddotfiles-8f4a4d47cbe50f24d5d87a326e01ec3a4360714b.tar.gz
dotfiles-8f4a4d47cbe50f24d5d87a326e01ec3a4360714b.tar.bz2
dotfiles-8f4a4d47cbe50f24d5d87a326e01ec3a4360714b.zip
Wont show panel item if off
Diffstat (limited to '.config')
-rwxr-xr-x.config/herbstluftwm/panel.sh84
1 files changed, 54 insertions, 30 deletions
diff --git a/.config/herbstluftwm/panel.sh b/.config/herbstluftwm/panel.sh
index a62616b..97fb5ba 100755
--- a/.config/herbstluftwm/panel.sh
+++ b/.config/herbstluftwm/panel.sh
@@ -77,47 +77,56 @@ hc pad $monitor $panel_height
77 77
78 while true ; do 78 while true ; do
79 # Volume 79 # Volume
80 volumes=$(\ 80 if pgrep pulseaudio > /dev/null ; then
81 amixer get Master | \ 81 volumes=$(\
82 grep Front\ 82 amixer get Master | \
83 ) 83 grep Front\
84 vol=$(\ 84 )
85 echo $volumes | \ 85 vol=$(\
86 sed "s/.*\[\([0-9]*\)%\].*/\1/"\ 86 echo $volumes | \
87 ) 87 sed "s/.*\[\([0-9]*\)%\].*/\1/"\
88 if [ -z $vol ] ; then 88 )
89 echo -e "volume\t^fg($normax_txt)Audio off" 89 if [ -z $vol ] ; then
90 elif [ $vol -le 0 ] ; then 90 echo -e "volume\toff"
91 echo -e "volume\t^fg($normal_txt)Volume muted" 91 elif [ $vol -le 0 ] ; then
92 echo -e "volume\t^fg($normal_txt)Volume muted"
93 else
94 echo -e "volume\t^fg($normal_txt)Volume: $vol%"
95 fi
92 else 96 else
93 echo -e "volume\t^fg($normal_txt)Volume: $vol%" 97 echo -e "volume\toff"
94 fi 98 fi
95 99
96 # Network 100 # Network
97 iwconfig=$(iwconfig wlp3s0) 101 iwconfig=$(iwconfig wlp3s0)
98 ssid=$(\ 102 if [ -z $iwconfig ] ; then
99 echo $iwconfig | \ 103 echo -e "wireless\toff"
100 sed "s/.*ESSID:\(\".*\"\).*/\1/" | \ 104 else
101 sed "s/.*\(off\/any\).*/\"\1\"/" | \ 105 ssid=$(\
102 sed "s/.*\"\(.*\)\".*/\1/"\
103 )
104 if [ $ssid = "off/any" ] ; then
105 echo -e "wireless\t^fg($normal_txt)Wlan: No connection"
106 else
107 IFS=',' read -a quality_info <<< $(\
108 echo $iwconfig | \ 106 echo $iwconfig | \
109 sed "s/.*Link Quality=\([0-9]*\)\/\([0-9]*\).*/\1,\2/"\ 107 sed "s/.*ESSID:\(\".*\"\).*/\1/" | \
108 sed "s/.*\(off\/any\).*/\"\1\"/" | \
109 sed "s/.*\"\(.*\)\".*/\1/"\
110 ) 110 )
111 cur_qual=${quality_info[0]} 111 if [ $ssid = "off/any" ] ; then
112 max_qual=${quality_info[1]} 112 ifconf=$
113 quality_p=$(echo "$cur_qual*100/$max_qual" | bc) 113 echo -e "wireless\t^fg($normal_txt)Wlan: No connection"
114 echo -e "wireless\t^fg($normal_txt)Wlan: $quality_p% ^fg($inactive_txt)($ssid)" 114 else
115 IFS=',' read -a quality_info <<< $(\
116 echo $iwconfig | \
117 sed "s/.*Link Quality=\([0-9]*\)\/\([0-9]*\).*/\1,\2/"\
118 )
119 cur_qual=${quality_info[0]}
120 max_qual=${quality_info[1]}
121 quality_p=$(echo "$cur_qual*100/$max_qual" | bc)
122 echo -e "wireless\t^fg($normal_txt)Wlan: $quality_p% ^fg($inactive_txt)($ssid)"
123 fi
115 fi 124 fi
116 125
117 # Battery 126 # Battery
118 IFS=' ' read -a batinfo <<< $(acpi -b) 127 IFS=' ' read -a batinfo <<< $(acpi -b)
119 if [ -z $batinfo ] ; then 128 if [ -z $batinfo ] ; then
120 echo -e "battery\t^fg($normax_txt)No battery" 129 echo -e "battery\toff"
121 else 130 else
122 charge=$(echo ${batinfo[3]} | tr -d '%,') 131 charge=$(echo ${batinfo[3]} | tr -d '%,')
123 if [ $charge -lt 15 ] ; then 132 if [ $charge -lt 15 ] ; then
@@ -187,7 +196,7 @@ hc pad $monitor $panel_height
187 echo -n "$separator" 196 echo -n "$separator"
188 echo -n "^bg()^fg() ${windowtitle//^/^^}" 197 echo -n "^bg()^fg() ${windowtitle//^/^^}"
189 # small adjustments 198 # small adjustments
190 right="$volume $separator^bg() $wireless $separator^bg() $battery $separator^bg() $date " 199 right="$volume$wireless$battery$date "
191 right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g') 200 right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
192 # get width of right aligned text.. and add some space.. 201 # get width of right aligned text.. and add some space..
193 width=$($textwidth "$font" "$right_text_only") 202 width=$($textwidth "$font" "$right_text_only")
@@ -212,12 +221,27 @@ hc pad $monitor $panel_height
212 ;; 221 ;;
213 volume) 222 volume)
214 volume="${cmd[@]:1}" 223 volume="${cmd[@]:1}"
224 if [ $volume == "off" ] ; then
225 volume=""
226 else
227 volume="$volume $separator^bg() "
228 fi
215 ;; 229 ;;
216 wireless) 230 wireless)
217 wireless="${cmd[@]:1}" 231 wireless="${cmd[@]:1}"
232 if [ $wireless = "off" ] ; then
233 wireless=""
234 else
235 wireless="$wireless $separator^bg() "
236 fi
218 ;; 237 ;;
219 battery) 238 battery)
220 battery="${cmd[@]:1}" 239 battery="${cmd[@]:1}"
240 if [ $battery == "off" ] ; then
241 battery=""
242 else
243 battery="$battery $separator^bg() "
244 fi
221 ;; 245 ;;
222 date) 246 date)
223 #echo "resetting date" >&2 247 #echo "resetting date" >&2