From 7c443c26978506533fa95b4b0f111ed9959f1ffe Mon Sep 17 00:00:00 2001 From: xero Date: Sun, 26 Apr 2015 10:22:30 -0400 Subject: update dzen2 bar and stalonetray --- herbstluftwm/.config/herbstluftwm/panel.sh | 118 +++++------------------------ 1 file changed, 18 insertions(+), 100 deletions(-) (limited to 'herbstluftwm') diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh index f33009d..4395b5b 100755 --- a/herbstluftwm/.config/herbstluftwm/panel.sh +++ b/herbstluftwm/.config/herbstluftwm/panel.sh @@ -18,19 +18,17 @@ fi # geometry has the format W H X Y x=${geometry[0]} y=${geometry[1]} -panel_width=${geometry[2]} +panel_width=548 panel_height=16 #font="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*" font="-Gohu-GohuFont-Medium-R-Normal--11-80-100-100-C-60-ISO10646-1" #font2="-misc-stlarch-medium-r-normal--10-100-75-75-c-80-iso10646-1" -bgcolor=$(hc get frame_bg_active_color) +bgcolor='#000000' selbg='#6A8C8C' selfg='#101010' -#### -# Try to find textwidth binary. -# In e.g. Ubuntu, this is named dzen2-textwidth. +# try to find textwidth binary. if which textwidth &> /dev/null ; then textwidth="textwidth"; elif which dzen2-textwidth &> /dev/null ; then @@ -39,10 +37,8 @@ else echo "This script requires the textwidth tool of the dzen2 project." exit 1 fi -#### -# true if we are using the svn version of dzen2 -# depending on version/distribution, this seems to have version strings like -# "dzen-" or "dzen-x.x.x-svn" + +# detect version if dzen2 -v 2>&1 | head -n 1 | grep -q '^dzen-\([^,]*-svn\|\),'; then dzen2_svn="true" else @@ -51,7 +47,6 @@ fi if awk -Wv 2>/dev/null | head -1 | grep -q '^mawk'; then # mawk needs "-W interactive" to line-buffer stdout correctly - # http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504 uniq_linebuffered() { awk -W interactive '$0 != l { print ; l=$0 ; fflush(); }' "$@" } @@ -66,7 +61,7 @@ fi hc pad $monitor $panel_height { - ### Event generator ### + ### event generator ### # based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this: # \t [...] # e.g. @@ -76,7 +71,7 @@ hc pad $monitor $panel_height while true ; do # "date" output is checked once a second, but an event is only # generated if the output changed compared to the previous run. - date +$'date\t ^ca(1,~/code/sys/calendar)^fg(#d9d9d9)^i(/usr/share/icons/stlarch_icons/clock1.xbm) ^fg(#efefef)%H:%M^fg(#bcbcbc) %Y-%m-^fg(#efefef)%d^ca() ' + date +$'date\t ^ca(1,~/code/sys/calendar)^fg(#d9d9d9)^i(/usr/share/icons/stlarch_icons/clock1.xbm) ^fg(#efefef)%H:%M^fg(#bcbcbc) %Y-%m-^fg(#efefef)%d^ca()' sleep 1 || break done > >(uniq_linebuffered) & childpid=$! @@ -89,35 +84,28 @@ hc pad $monitor $panel_height windowtitle="" while true ; do - ### Output ### - # This part prints dzen data based on the _previous_ data handling run, + ### output ### + # this part prints dzen data based on the _previous_ data handling run, # and then waits for the next event to happen. - bordercolor="#26221C"tags - separator=" " - xicon="#d9d9d9" - xtitle="#bcbcbc" - xfg="#ffffff" - xext="#909090" - cool="#6A8C8C" - hot="#990000" + echo -n "^bg($bgcolor)$date ^bg(#111111) " # draw tags for i in "${tags[@]}" ; do case ${i:0:1} in '#') - echo -n "^bg(#6A8C8C)^fg(#101010)" + echo -n "^bg(#5F8787)^fg(#101010)" ;; '+') echo -n "^bg(#666666)^fg(#141414)" ;; ':') - echo -n "^bg(#222222)^fg(#ffffff)" + echo -n "^bg(#3a3a3a)^fg(#bcbcbc)" ;; '!') echo -n "^bg(#F92672)^fg(#141414)" ;; *) - echo -n "^bg($bgcolor)^fg($xtitle)" + echo -n "^bg(#222222)^fg(#bcbcbc)" ;; esac if [ ! -z "$dzen2_svn" ] ; then @@ -132,84 +120,14 @@ hc pad $monitor $panel_height echo -n " ${i:1} " fi done - echo -n "$separator" - #echo -n "^bg()^fg() ${windowtitle//^/^^}" - temp=`sensors | awk '/Core\ 0/ {gsub(/\+/,"",$3); gsub(/\..+/,"",$3); print $3}'` - # temp heat colorizing - if (($temp<=50)) - then - temp="^fg($cool)$temp" - elif (($temp>50 && $temp<=75)) - then - temp="^fg($xfg)$temp" - elif (($temp>76)) - then - temp="^fg($hot)$temp" - else - temp="^fg($xfg)$temp" - fi - temp="^fg($xicon)^i(/usr/share/icons/stlarch_icons/temp1.xbm) ^fg($xtitle)temp $temp^fg($xext)°c" - #up time - upSeconds=`cat /proc/uptime`; - upSeconds=${upSeconds%%.*}; - let secs=$((${upSeconds}%60)) - let mins=$((${upSeconds}/60%60)) - let hours=$((${upSeconds}/3600%24)) - let days=$((${upSeconds}/86400)) - uptime="^fg($xicon)^i(/usr/share/icons/stlarch_icons/uparrow1.xbm) ^fg($xtitle)uptime ^fg($xfg)${days}^fg($xext)d ^fg($xfg)${hours}^fg($xext)h ^fg($xfg)${mins}^fg($xext)m" - #pacman updates - updates=`pacman -Quq | wc -l` - updates="^fg($xicon)^i(/usr/share/icons/stlarch_icons/pacman1.xbm) ^fg($xtitle)pacman ^fg($xfg)$updates" - #cpu - cpu=`mpstat | awk '$3 ~ /CPU/ { for(i=1;i<=NF;i++) { if ($i ~ /%idle/) field=i } } $3 ~ /all/ { print 100 - $field }'` - cpu="^fg($xicon)^i(/usr/share/icons/stlarch_icons/cpu1.xbm) ^fg($xtitle)cpu ^fg($xfg)$cpu^fg($xext)%" - #memory - mem=`free | awk '/Mem:/ {print int($3/$2 * 100.0)}'` - mem="^fg($xicon)^i(/usr/share/icons/stlarch_icons/mem1.xbm) ^fg($xtitle)ram ^fg($xfg)$mem^fg($xext)%" - #battery - bat=`cat /sys/class/power_supply/BAT1/capacity` - batstat=`cat /sys/class/power_supply/BAT1/status` - if (($batstat=='Charging')) - then - batico="^i(/usr/share/icons/stlarch_icons/ac10.xbm)" - else - batico="^i(/usr/share/icons/stlarch_icons/batt5full.xbm)" - fi - bat="^fg($xicon)$batico ^fg($xtitle)battery ^fg($xfg)$bat^fg($xext)%" - #cyberspace - # read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` - # if iwconfig $int1 >/dev/null 2>&1; then - # wifi=$int1 - # eth0=$int2 - # else - # wifi=$int2 - # eth0=$int1 - # fi - # ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 || int=$wifi - # if (($int==$wifi)) - # then - # net="^fg($xicon)^i(/usr/share/icons/stlarch_icons/wireless5.xbm) ^fg($xtitle)network ^fg($xfg)wifi" - # elif (($int==$eth0)) - # then - # net="^fg($xicon)^i(/usr/share/icons/stlarch_icons/ac5.xbm) ^fg($xtitle)network ^fg($xfg)ethernet" - # else - # net="^fg($xicon)^i(/usr/share/icons/stlarch_icons/dice5.xbm) ^fg($xtitle)network ^fg($xfg)disconnected" - # fi - #combine - right="^bg($bgcolor) $cpu $separator $mem $separator $temp $separator $bat $separator $updates $separator $uptime $date $separator $separator" - - right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g') - # get width of right aligned text.. and add some space.. - width=$($textwidth "$font" "$right_text_only ") - echo -n "^pa($(($panel_width - $width)))$right" echo - ### Data handling ### - # This part handles the events generated in the event loop, and sets + ### data handling ### + # this part handles the events generated in the event loop, and sets # internal variables based on them. The event and its arguments are # read into the array cmd, then action is taken depending on the event # name. - # "Special" events (quit_panel/togglehidepanel/reload) are also handled + # "special" events (quit_panel/togglehidepanel/reload) are also handled # here. # wait for next event @@ -256,12 +174,12 @@ hc pad $monitor $panel_height done ### dzen2 ### - # After the data is gathered and processed, the output of the previous block - # gets piped to dzen2. + # after the data is gathered and processed, pipe the output to dzen2. } 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \ -e 'button3=;button4=exec:herbstclient use_index -1;button5=exec:herbstclient use_index +1' \ -ta l -bg "$bgcolor" -fg '#efefef' & +#wait 2 seconds then load the stand alone tray sleep 2 stalonetray -- cgit v1.2.1