From b3970e6695d30f87e9e982103f5fcf8ca60ce71e Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Mon, 5 May 2014 22:56:05 +0200 Subject: Updates to panel - added charging - added better cross color support --- .config/herbstluftwm/autostart | 16 ++++++----- .config/herbstluftwm/panel.sh | 60 ++++++++++++++++++++++++++++++------------ 2 files changed, 52 insertions(+), 24 deletions(-) (limited to '.config/herbstluftwm') diff --git a/.config/herbstluftwm/autostart b/.config/herbstluftwm/autostart index 500eabf..51dcd9d 100755 --- a/.config/herbstluftwm/autostart +++ b/.config/herbstluftwm/autostart @@ -3,7 +3,7 @@ # this is a simple config for herbstluftwm #Wallpaper -WALLPAPER=/usr/share/backgrounds/gnome/Road.jpg +WALLPAPER=/home/tom/Pictures/ThDLxEW.jpg #Numix color palette LIGHT='#f9f9f9' @@ -12,6 +12,9 @@ ACCENT='#d64937' LDARK='#333333' DARK='#2d2d2d' +#Panel +PANEL_HEIGHT=24 + hc() { herbstclient "$@" } @@ -24,15 +27,13 @@ xsetroot -solid $ACCENT hc keyunbind --all # keybindings -# if you have a super key you will be much happier with Mod set to Mod4 -#Mod=Mod1 # Use alt as the main modifier Mod=Mod4 # Use the super key as the main modifier hc keybind $Mod-Shift-q quit hc keybind $Mod-Shift-r reload hc keybind $Mod-Shift-c close hc keybind $Mod-Return spawn xfce4-terminal -hc keybind ~ spawn xfce4-terminal --drop-down +hc keybind $Mod-grave spawn dmenu_run -h $PANEL_HEIGHT -p "Run:" -nb $DARK -nf $LIGHT -sb $ACCENT -sf $DARK # basic movement # focusing clients @@ -74,7 +75,7 @@ hc keybind $Mod-Control-Up resize up +$resizestep hc keybind $Mod-Control-Right resize right +$resizestep # tags -tag_names=( {1..9} ) +tag_names=( I II III IV V VI VII VIII IX X ) tag_keys=( {1..9} 0 ) # Selecting workspaces @@ -136,7 +137,7 @@ hc attr theme.inner_color $DARK hc attr theme.border_width 3 hc attr theme.floating.border_width 4 hc attr theme.floating.outer_width 1 -hc attr theme.floating.outer_color black +hc attr theme.floating.outer_color $DARk hc attr theme.active.inner_color $DARK hc attr theme.active.outer_color $DARK hc attr theme.background_color $DARK @@ -171,7 +172,8 @@ herbstclient set tree_style '╾│ ├└╼─┐' #Start panel in all monitors start_panel() { for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do - "$1" $monitor & + "$1" $monitor $PANEL_HEIGHT $LIGHT $LLIGHT $ACCENT $LDARK $DARK + $2& done } 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 x=${geometry[0]} y=${geometry[1]} panel_width=${geometry[2]} -panel_height=24 + +panel_height=$2 +light=$3 +llight=$4 +accent=$5 +ldark=$6 +dark=$7 + font="-*-fixed-medium-*-*-*-14-*-*-*-*-*-*-*" -bgcolor=$(hc get frame_border_normal_color) -selbg=$(hc get window_border_active_color) -selfg='#101010' +selected_bg=$accent +normal_bg=$dark +selected_txt=$dark +normal_txt=$light +inactive_txt=$llight ######################################################################################## # Try to find textwidth binary. @@ -65,11 +74,24 @@ hc pad $monitor $panel_height # e.g. # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29 - #mpc idleloop player & 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^fg(#efefef)%H:%M:%S^fg(#909090), %Y-%m-^fg(#efefef)%d' + # Network + + + # Battery + IFS=' ' read -a batinfo <<< $(acpi -b) + charge=$(echo ${batinfo[3]} | tr -d '%,') + if [ $charge -lt 15 ] ; then + bat_color=$accent + else + bat_color=$normal_txt + fi + state=$(echo ${batinfo[2]} | tr -d ',') + remaining=$(echo ${batinfo[4]}) + echo -e "battery\t^fg($normal_txt)$state: ^fg($bat_color)$charge^fg($normal_txt)% ^fg($inactive_txt)($remaining)" + + # Time + echo -e $(date +$"date\t^fg($normal_txt)%H:%M:%S^fg($inactive_txt), %d-%m-%Y") sleep 1 || break done > >(uniq_linebuffered) & childpid=$! @@ -80,6 +102,7 @@ hc pad $monitor $panel_height IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" visible=true date="" + battery="" windowtitle="" while true ; do @@ -88,24 +111,24 @@ hc pad $monitor $panel_height # and then waits for the next event to happen. bordercolor="#26221C" - separator="^bg()^fg($selbg)|" + separator="^bg()^fg($accent)|" # draw tags for i in "${tags[@]}" ; do case ${i:0:1} in '#') - echo -n "^bg($selbg)^fg($selfg)" + echo -n "^bg($selected_bg)^fg($selected_txt)" ;; '+') - echo -n "^bg(#9CA668)^fg(#141414)" + echo -n "^bg($accent)^fg($normal_bg)" ;; ':') - echo -n "^bg()^fg(#ffffff)" + echo -n "^bg()^fg($normal_txt)" ;; '!') - echo -n "^bg(#FF0675)^fg(#141414)" + echo -n "^bg($normal_txt)^fg($normal_bg)" ;; *) - echo -n "^bg()^fg(#ababab)" + echo -n "^bg()^fg($inactive_txt)" ;; esac if [ ! -z "$dzen2_svn" ] ; then @@ -122,10 +145,10 @@ hc pad $monitor $panel_height echo -n "$separator" echo -n "^bg()^fg() ${windowtitle//^/^^}" # small adjustments - right="$separator^bg() $date $separator" + right="$battery $separator^bg() $date " 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 ") + width=$($textwidth "$font" "$right_text_only") echo -n "^pa($(($panel_width - $width)))$right" echo @@ -145,6 +168,9 @@ hc pad $monitor $panel_height #echo "resetting tags" >&2 IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" ;; + battery) + battery="${cmd[@]:1}" + ;; date) #echo "resetting date" >&2 date="${cmd[@]:1}" @@ -186,4 +212,4 @@ hc pad $monitor $panel_height } 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' + -ta l -bg "$normal_bg" -fg "$normal_txt" -- cgit v1.2.3