aboutsummaryrefslogtreecommitdiffstats
path: root/.config/herbstluftwm/panel.sh
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2014-05-05 22:56:05 +0200
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2014-05-05 22:56:05 +0200
commitb3970e6695d30f87e9e982103f5fcf8ca60ce71e (patch)
treec81d5fda246e36e750626aa540555ae24db60538 /.config/herbstluftwm/panel.sh
parent5ccd9443215ccfbec547e109ea28becabde711c1 (diff)
downloaddotfiles-b3970e6695d30f87e9e982103f5fcf8ca60ce71e.tar.gz
dotfiles-b3970e6695d30f87e9e982103f5fcf8ca60ce71e.tar.bz2
dotfiles-b3970e6695d30f87e9e982103f5fcf8ca60ce71e.zip
Updates to panel
- added charging - added better cross color support
Diffstat (limited to '.config/herbstluftwm/panel.sh')
-rwxr-xr-x.config/herbstluftwm/panel.sh60
1 files changed, 43 insertions, 17 deletions
diff --git a/.config/herbstluftwm/panel.sh b/.config/herbstluftwm/panel.sh
index cc4fb1e..0dcf370 100755
--- a/.config/herbstluftwm/panel.sh
+++ b/.config/herbstluftwm/panel.sh
@@ -11,11 +11,20 @@ fi
11x=${geometry[0]} 11x=${geometry[0]}
12y=${geometry[1]} 12y=${geometry[1]}
13panel_width=${geometry[2]} 13panel_width=${geometry[2]}
14panel_height=24 14
15panel_height=$2
16light=$3
17llight=$4
18accent=$5
19ldark=$6
20dark=$7
21
15font="-*-fixed-medium-*-*-*-14-*-*-*-*-*-*-*" 22font="-*-fixed-medium-*-*-*-14-*-*-*-*-*-*-*"
16bgcolor=$(hc get frame_border_normal_color) 23selected_bg=$accent
17selbg=$(hc get window_border_active_color) 24normal_bg=$dark
18selfg='#101010' 25selected_txt=$dark
26normal_txt=$light
27inactive_txt=$llight
19 28
20######################################################################################## 29########################################################################################
21# Try to find textwidth binary. 30# Try to find textwidth binary.
@@ -65,11 +74,24 @@ hc pad $monitor $panel_height
65 # e.g. 74 # e.g.
66 # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29 75 # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
67 76
68 #mpc idleloop player &
69 while true ; do 77 while true ; do
70 # "date" output is checked once a second, but an event is only 78 # Network
71 # generated if the output changed compared to the previous run. 79
72 date +$'date\t^fg(#efefef)%H:%M:%S^fg(#909090), %Y-%m-^fg(#efefef)%d' 80
81 # Battery
82 IFS=' ' read -a batinfo <<< $(acpi -b)
83 charge=$(echo ${batinfo[3]} | tr -d '%,')
84 if [ $charge -lt 15 ] ; then
85 bat_color=$accent
86 else
87 bat_color=$normal_txt
88 fi
89 state=$(echo ${batinfo[2]} | tr -d ',')
90 remaining=$(echo ${batinfo[4]})
91 echo -e "battery\t^fg($normal_txt)$state: ^fg($bat_color)$charge^fg($normal_txt)% ^fg($inactive_txt)($remaining)"
92
93 # Time
94 echo -e $(date +$"date\t^fg($normal_txt)%H:%M:%S^fg($inactive_txt), %d-%m-%Y")
73 sleep 1 || break 95 sleep 1 || break
74 done > >(uniq_linebuffered) & 96 done > >(uniq_linebuffered) &
75 childpid=$! 97 childpid=$!
@@ -80,6 +102,7 @@ hc pad $monitor $panel_height
80 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" 102 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
81 visible=true 103 visible=true
82 date="" 104 date=""
105 battery=""
83 windowtitle="" 106 windowtitle=""
84 while true ; do 107 while true ; do
85 108
@@ -88,24 +111,24 @@ hc pad $monitor $panel_height
88 # and then waits for the next event to happen. 111 # and then waits for the next event to happen.
89 112
90 bordercolor="#26221C" 113 bordercolor="#26221C"
91 separator="^bg()^fg($selbg)|" 114 separator="^bg()^fg($accent)|"
92 # draw tags 115 # draw tags
93 for i in "${tags[@]}" ; do 116 for i in "${tags[@]}" ; do
94 case ${i:0:1} in 117 case ${i:0:1} in
95 '#') 118 '#')
96 echo -n "^bg($selbg)^fg($selfg)" 119 echo -n "^bg($selected_bg)^fg($selected_txt)"
97 ;; 120 ;;
98 '+') 121 '+')
99 echo -n "^bg(#9CA668)^fg(#141414)" 122 echo -n "^bg($accent)^fg($normal_bg)"
100 ;; 123 ;;
101 ':') 124 ':')
102 echo -n "^bg()^fg(#ffffff)" 125 echo -n "^bg()^fg($normal_txt)"
103 ;; 126 ;;
104 '!') 127 '!')
105 echo -n "^bg(#FF0675)^fg(#141414)" 128 echo -n "^bg($normal_txt)^fg($normal_bg)"
106 ;; 129 ;;
107 *) 130 *)
108 echo -n "^bg()^fg(#ababab)" 131 echo -n "^bg()^fg($inactive_txt)"
109 ;; 132 ;;
110 esac 133 esac
111 if [ ! -z "$dzen2_svn" ] ; then 134 if [ ! -z "$dzen2_svn" ] ; then
@@ -122,10 +145,10 @@ hc pad $monitor $panel_height
122 echo -n "$separator" 145 echo -n "$separator"
123 echo -n "^bg()^fg() ${windowtitle//^/^^}" 146 echo -n "^bg()^fg() ${windowtitle//^/^^}"
124 # small adjustments 147 # small adjustments
125 right="$separator^bg() $date $separator" 148 right="$battery $separator^bg() $date "
126 right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g') 149 right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g')
127 # get width of right aligned text.. and add some space.. 150 # get width of right aligned text.. and add some space..
128 width=$($textwidth "$font" "$right_text_only ") 151 width=$($textwidth "$font" "$right_text_only")
129 echo -n "^pa($(($panel_width - $width)))$right" 152 echo -n "^pa($(($panel_width - $width)))$right"
130 echo 153 echo
131 154
@@ -145,6 +168,9 @@ hc pad $monitor $panel_height
145 #echo "resetting tags" >&2 168 #echo "resetting tags" >&2
146 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" 169 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)"
147 ;; 170 ;;
171 battery)
172 battery="${cmd[@]:1}"
173 ;;
148 date) 174 date)
149 #echo "resetting date" >&2 175 #echo "resetting date" >&2
150 date="${cmd[@]:1}" 176 date="${cmd[@]:1}"
@@ -186,4 +212,4 @@ hc pad $monitor $panel_height
186 212
187} 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \ 213} 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \
188 -e 'button3=;button4=exec:herbstclient use_index -1;button5=exec:herbstclient use_index +1' \ 214 -e 'button3=;button4=exec:herbstclient use_index -1;button5=exec:herbstclient use_index +1' \
189 -ta l -bg "$bgcolor" -fg '#efefef' 215 -ta l -bg "$normal_bg" -fg "$normal_txt"