From 54472dfc9bd4bb01823329b9e701447adb9e49ea Mon Sep 17 00:00:00 2001 From: shmibs Date: Thu, 13 Feb 2014 22:45:39 -0700 Subject: added client list to dzen panel it lags slightly, but clients are now shown in the bar by instance name with the currently focuses client highlit. maybe a fixed-length method using method titles would be better? i could divide the panel space by the total number of clients and give no more than that many to each client title. that would make things lag even more, though... --- .config/herbstluftwm/autostart | 31 ++++--- .config/herbstluftwm/panel.sh | 47 ++++++---- .config/herbstluftwm/panel.sh.bak | 184 -------------------------------------- 3 files changed, 46 insertions(+), 216 deletions(-) delete mode 100755 .config/herbstluftwm/panel.sh.bak diff --git a/.config/herbstluftwm/autostart b/.config/herbstluftwm/autostart index ea83f12..a786a58 100755 --- a/.config/herbstluftwm/autostart +++ b/.config/herbstluftwm/autostart @@ -49,11 +49,14 @@ hc keybind $Mod-a cycle -1 # create an empty frame at the specified direction hc keybind $Mod-s chain .-. lock .-. split bottom 0.5 .-. focus -e d .-. unlock hc keybind $Mod-v chain .-. lock .-. split right 0.5 .-. focus -e r .-. unlock +# create an empty frame and shift the currently focused client into it +hc keybind $Mod-Control-s chain .-. lock .-. split bottom 0.5 .-. shift down .-. unlock +hc keybind $Mod-Control-v chain .-. lock .-. split right 0.5 .-. shift right .-. unlock # let the current frame explode into subframes hc keybind $Mod-Shift-space split explode # resizing frames -resizestep=0.05 +resizestep=0.04 hc keybind $Mod-Control-h resize left +$resizestep hc keybind $Mod-Control-j resize down +$resizestep hc keybind $Mod-Control-k resize up +$resizestep @@ -101,17 +104,17 @@ hc keybind XF86PowerOff spawn mate-session-save --shutdown-dialog hc keybind Print spawn mate-screenshot # ranger -hc keybind $Mod-Shift-Control-Return spawn urxvt -e ranger /home/shmibs -hc keybind $Mod-Shift-Control-b spawn urxvt -e ranger /home/shmibs/backdrops -hc keybind $Mod-Shift-Control-c spawn urxvt -e ranger /home/shmibs/comics -hc keybind $Mod-Shift-Control-d spawn urxvt -e ranger /home/shmibs/downloads -hc keybind $Mod-Shift-Control-s spawn urxvt -e ranger /home/shmibs/desktop -hc keybind $Mod-Shift-Control-m spawn urxvt -e ranger /home/shmibs/music -hc keybind $Mod-Shift-Control-g spawn urxvt -e ranger /home/shmibs/games -hc keybind $Mod-Shift-Control-p spawn urxvt -e ranger /home/shmibs/projects -hc keybind $Mod-Shift-Control-i spawn urxvt -e ranger /home/shmibs/images -hc keybind $Mod-Shift-Control-t spawn urxvt -e ranger /home/shmibs/thcool -hc keybind $Mod-Shift-Control-v spawn urxvt -e ranger /home/shmibs/videos +hc keybind $Mod-Shift-Control-Return spawn urxvt -name "ranger" -e ranger /home/shmibs +hc keybind $Mod-Shift-Control-b spawn urxvt -name "ranger" -e ranger /home/shmibs/backdrops +hc keybind $Mod-Shift-Control-c spawn urxvt -name "ranger" -e ranger /home/shmibs/comics +hc keybind $Mod-Shift-Control-d spawn urxvt -name "ranger" -e ranger /home/shmibs/downloads +hc keybind $Mod-Shift-Control-s spawn urxvt -name "ranger" -e ranger /home/shmibs/desktop +hc keybind $Mod-Shift-Control-m spawn urxvt -name "ranger" -e ranger /home/shmibs/music +hc keybind $Mod-Shift-Control-g spawn urxvt -name "ranger" -e ranger /home/shmibs/games +hc keybind $Mod-Shift-Control-p spawn urxvt -name "ranger" -e ranger /home/shmibs/projects +hc keybind $Mod-Shift-Control-i spawn urxvt -name "ranger" -e ranger /home/shmibs/images +hc keybind $Mod-Shift-Control-t spawn urxvt -name "ranger" -e ranger /home/shmibs/thcool +hc keybind $Mod-Shift-Control-v spawn urxvt -name "ranger" -e ranger /home/shmibs/videos # spawn hc keybind $Mod-Return spawn urxvt @@ -122,8 +125,8 @@ hc keybind $Mod-Shift-i spawn gimp hc keybind $Mod-Shift-m spawn mathematica hc keybind $Mod-Shift-o spawn ~/stuffs/tor/start-tor-browser hc keybind $Mod-Shift-t spawn transmission-gtk -hc keybind $Mod-Shift-v spawn urxvt -e vim -hc keybind $Mod-Shift-w spawn urxvt -e weechat +hc keybind $Mod-Shift-v spawn urxvt -name "vim" -e vim +hc keybind $Mod-Shift-w spawn urxvt -name "weechat" -e weechat # banshee hc keybind $Mod-Shift-Up spawn banshee --show diff --git a/.config/herbstluftwm/panel.sh b/.config/herbstluftwm/panel.sh index 5b365af..a0621b6 100755 --- a/.config/herbstluftwm/panel.sh +++ b/.config/herbstluftwm/panel.sh @@ -15,7 +15,7 @@ panel_height=18 font="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*" bgcolor=$(hc get frame_border_normal_color) selbg=$(hc get window_border_active_color) -selfg='#101010' +selfg='#fefefe' #### # Try to find textwidth binary. @@ -65,7 +65,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^fg(#efefef)%a, %b %d, %H:%M:%S' + date +$'date\t^fg(#efefef)%a, %b %d, %H:%M' sleep 1 || break done > >(uniq_linebuffered) & childpid=$! @@ -75,7 +75,8 @@ hc pad $monitor $panel_height IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" visible=true date="" - windowtitle="" + clients="" + focus_index="" while true ; do ### Output ### @@ -103,24 +104,24 @@ hc pad $monitor $panel_height echo -n "^bg()^fg(#ababab)" ;; esac - if [ ! -z "$dzen2_svn" ] ; then - # clickable tags if using SVN dzen - echo -n "^ca(1,\"${herbstclient_command[@]:-herbstclient}\" " - echo -n "focus_monitor \"$monitor\" && " - echo -n "\"${herbstclient_command[@]:-herbstclient}\" " - echo -n "use \"${i:1}\") ${i:1} ^ca()" - else - # non-clickable tags if using older dzen - echo -n " ${i:1} " - fi + # non-clickable tags, because i don't care + echo -n " ${i:1} " done - echo -n "$separator" - echo -n "^bg()^fg() ${windowtitle//^/^^}" + echo -n "$separator^fg()" + + for i in "${!clients[@]}"; do + if [ $i -eq $focus_index ]; then + echo -n "^bg($selbg)^fg($selfg) ${clients[i]} ^bg()^fg()" + else + echo -n " ${clients[i]} " + fi + done + # small adjustments right="$separator^bg() $date $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 ") + width=$($textwidth "$font" "$right_text_only ") echo -n "^pa($(($panel_width - $width)))$right" echo @@ -168,7 +169,17 @@ hc pad $monitor $panel_height exit ;; focus_changed|window_title_changed) - windowtitle="${cmd[@]:2}" + clients=($(herbstclient layout | grep -Eo '0x[0-9a-f]*')) focus_client=$(herbstclient get_attr clients.focus.winid) + focus_index="" + hc_args="herbstclient chain" + for i in "${!clients[@]}"; do + if [ "${clients[i]}" == "$focus_client" ]; then + focus_index=$i + fi + hc_args="$hc_args"" .-. get_attr clients.""${clients[i]}"".instance .-. echo" + done + + clients=($($hc_args)) ;; #player) # ;; @@ -180,5 +191,5 @@ hc pad $monitor $panel_height # gets piped to dzen2. } 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \ - -e 'button3=' \ + -e 'button3=;button4=exec:herbstclient use_index -1;button5=exec:herbstclient use_index +1' \ -ta l -bg "$bgcolor" -fg '#efefef' diff --git a/.config/herbstluftwm/panel.sh.bak b/.config/herbstluftwm/panel.sh.bak deleted file mode 100755 index 8c75b5c..0000000 --- a/.config/herbstluftwm/panel.sh.bak +++ /dev/null @@ -1,184 +0,0 @@ -#!/bin/bash - -hc() { "${herbstclient_command[@]:-herbstclient}" "$@" ;} -monitor=${1:-0} -geometry=( $(herbstclient monitor_rect "$monitor") ) -if [ -z "$geometry" ] ;then - echo "Invalid monitor $monitor" - exit 1 -fi -# geometry has the format W H X Y -x=${geometry[0]} -y=${geometry[1]} -panel_width=${geometry[2]} -panel_height=18 -font="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*" -bgcolor=$(hc get frame_border_normal_color) -selbg=$(hc get window_border_active_color) -selfg='#101010' - -#### -# Try to find textwidth binary. -# In e.g. Ubuntu, this is named dzen2-textwidth. -if which textwidth &> /dev/null ; then - textwidth="textwidth"; -elif which dzen2-textwidth &> /dev/null ; then - textwidth="dzen2-textwidth"; -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" -if dzen2 -v 2>&1 | head -n 1 | grep -q '^dzen-\([^,]*-svn\|\),'; then - dzen2_svn="true" -else - dzen2_svn="" -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(); }' "$@" - } -else - # other awk versions (e.g. gawk) issue a warning with "-W interactive", so - # we don't want to use it there. - uniq_linebuffered() { - awk '$0 != l { print ; l=$0 ; fflush(); }' "$@" - } -fi - -hc pad $monitor $panel_height - -{ - ### Event generator ### - # based on different input data (mpc, date, hlwm hooks, ...) this generates events, formed like this: - # \t [...] - # 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^fg(#909090), %Y-%m-^fg(#efefef)%d' - sleep 1 || break - done > >(uniq_linebuffered) & - childpid=$! - hc --idle - kill $childpid -} 2> /dev/null | { - IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" - visible=true - date="" - windowtitle="" - while true ; do - - ### Output ### - # This part prints dzen data based on the _previous_ data handling run, - # and then waits for the next event to happen. - - bordercolor="#26221C" - separator="^bg()^fg($selbg)|" - # draw tags - for i in "${tags[@]}" ; do - case ${i:0:1} in - '#') - echo -n "^bg($selbg)^fg($selfg)" - ;; - '+') - echo -n "^bg(#9CA668)^fg(#141414)" - ;; - ':') - echo -n "^bg()^fg(#ffffff)" - ;; - '!') - echo -n "^bg(#FF0675)^fg(#141414)" - ;; - *) - echo -n "^bg()^fg(#ababab)" - ;; - esac - if [ ! -z "$dzen2_svn" ] ; then - # clickable tags if using SVN dzen - echo -n "^ca(1,\"${herbstclient_command[@]:-herbstclient}\" " - echo -n "focus_monitor \"$monitor\" && " - echo -n "\"${herbstclient_command[@]:-herbstclient}\" " - echo -n "use \"${i:1}\") ${i:1} ^ca()" - else - # non-clickable tags if using older dzen - echo -n " ${i:1} " - fi - done - echo -n "$separator" - echo -n "^bg()^fg() ${windowtitle//^/^^}" - # small adjustments - right="$separator^bg() $date $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 - # 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 - # here. - - # wait for next event - IFS=$'\t' read -ra cmd || break - # find out event origin - case "${cmd[0]}" in - tag*) - #echo "resetting tags" >&2 - IFS=$'\t' read -ra tags <<< "$(hc tag_status $monitor)" - ;; - date) - #echo "resetting date" >&2 - date="${cmd[@]:1}" - ;; - quit_panel) - exit - ;; - togglehidepanel) - currentmonidx=$(hc list_monitors | sed -n '/\[FOCUS\]$/s/:.*//p') - if [ "${cmd[1]}" -ne "$monitor" ] ; then - continue - fi - if [ "${cmd[1]}" = "current" ] && [ "$currentmonidx" -ne "$monitor" ] ; then - continue - fi - echo "^togglehide()" - if $visible ; then - visible=false - hc pad $monitor 0 - else - visible=true - hc pad $monitor $panel_height - fi - ;; - reload) - exit - ;; - focus_changed|window_title_changed) - windowtitle="${cmd[@]:2}" - ;; - #player) - # ;; - esac - done - - ### dzen2 ### - # After the data is gathered and processed, the output of the previous block - # gets piped to dzen2. - -} 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \ - -e 'button3=' \ - -ta l -bg "$bgcolor" -fg '#efefef' -- cgit v1.2.3