Commits

firefly  committed 4078b71

Adding herbstluftwm config.

  • Participants
  • Parent commits 566c216

Comments (0)

Files changed (3)

 # ignore file extensions
 ~$
 \.pacsave$
+\..*\.sw.$

File config/herbstluftwm/autostart

+#!/bin/bash
+
+# this is a simple config for herbstluftwm
+
+function hc() {
+    herbstclient "$@"
+}
+
+hc emit_hook reload
+
+#xsetroot -solid '#5A8E3A'
+xsetroot -solid '#111111'
+
+
+# remove all existing keybindings
+hc keyunbind --all
+
+# keybindings
+#Mod=Mod1
+Mod=Mod4
+Term=pangoterm
+
+hc keybind $Mod-Shift-q quit
+hc keybind $Mod-Shift-r reload
+hc keybind $Mod-Shift-c close
+#hc keybind $Mod-Return spawn xterm
+hc keybind $Mod-Return spawn $Term
+
+# tags
+TAG_NAMES=( {1..9} )
+TAG_KEYS=( {1..9} 0 )
+
+hc rename default "${TAG_NAMES[0]}" || true
+for i in ${!TAG_NAMES[@]} ; do
+    hc add "${TAG_NAMES[$i]}"
+    key="${TAG_KEYS[$i]}"
+    if ! [ -z "$key" ] ; then
+        hc keybind "$Mod-$key" use_index "$i"
+        hc keybind "$Mod-Shift-$key" move_index "$i"
+    fi
+done
+
+# cycle through tags
+hc keybind $Mod-period use_index +1 --skip-visible
+hc keybind $Mod-comma  use_index -1 --skip-visible
+hc keybind $Mod-Right use_index +1 --skip-visible
+hc keybind $Mod-Left  use_index -1 --skip-visible
+
+# layouting
+hc keybind $Mod-d remove
+hc keybind $Mod-space       cycle_layout +1
+hc keybind $Mod-Shift-space cycle_layout -1
+hc keybind $Mod-minus split vertical 0.5
+hc keybind $Mod-v split horizontal 0.5
+hc keybind $Mod-f floating toggle
+hc keybind $Mod-m fullscreen toggle
+hc keybind $Mod-p pseudotile toggle
+
+# resizing
+RESIZESTEP=0.05
+hc keybind $Mod-Control-h resize left +$RESIZESTEP
+hc keybind $Mod-Control-t resize down +$RESIZESTEP
+hc keybind $Mod-Control-n resize up +$RESIZESTEP
+hc keybind $Mod-Control-s resize right +$RESIZESTEP
+
+# mouse
+hc mouseunbind --all
+hc mousebind $Mod-Button1 move
+hc mousebind $Mod-Button2 resize
+hc mousebind $Mod-Button3 zoom
+
+# focus
+hc keybind $Mod-BackSpace   cycle_monitor
+hc keybind $Mod-Tab         cycle_all +1
+hc keybind $Mod-Shift-Tab   cycle_all -1
+hc keybind $Mod-c cycle
+
+hc keybind $Mod-h focus left
+hc keybind $Mod-t focus down
+hc keybind $Mod-n focus up
+hc keybind $Mod-s focus right
+
+#hc keybind $Mod-i jumpto urgent
+hc keybind $Mod-a jumpto urgent
+
+hc keybind $Mod-Shift-h shift left
+hc keybind $Mod-Shift-t shift down
+hc keybind $Mod-Shift-n shift up
+hc keybind $Mod-Shift-s shift right
+
+# colors
+#hc set frame_border_active_color '#994422'
+#hc set frame_border_normal_color '#101010'
+#hc set frame_bg_active_color '#345F0C'
+#hc set window_border_normal_color '#454545'
+#hc set window_border_active_color '#9fbc00'
+#hc set window_border_active_color '#00ff00'
+
+hc set frame_border_active_color '#aa5500'
+hc set window_border_active_color '#aa5500'
+hc set frame_bg_active_color '#080808'
+
+hc set frame_border_normal_color '#222222'
+hc set window_border_normal_color '#222222'
+hc set frame_bg_normal_color '#111111'
+
+hc set frame_border_width 1
+hc set window_border_width 1
+hc set window_border_inner_width 0
+hc set always_show_frame 1
+hc set frame_gap 8
+# add overlapping window borders
+hc set window_gap -1
+hc set frame_padding 0
+hc set smart_window_surroundings 1
+hc set smart_frame_surroundings 0
+
+
+# rules
+hc unrule -F
+#hc rule class=XTerm tag=3 # move all xterms to tag 3
+hc rule focus=off # normally do not focus new clients
+# give focus to most common terminals
+hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on
+hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' pseudotile=on
+hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
+hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK)' manage=off
+
+# unlock, just to be sure
+hc unlock
+
+herbstclient set tree_style '╾│ ├└╼─┐'
+
+# do multi monitor setup here, e.g.:
+# hc remove_monitor 1
+# hc move_monitor 0 1280x1024+0+0
+# hc add_monitor 1280x1024+1280+0
+
+# find the panel
+panel=~/.config/herbstluftwm/panel.sh
+[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
+for monitor in $(herbstclient list_monitors | cut -d: -f1) ; do
+    # start it on each monitor
+    $panel $monitor &
+done
+

File config/herbstluftwm/panel.sh

+#!/bin/bash
+
+# disable path name expansion or * will be expanded in the line
+# cmd=( $line )
+set -f
+
+monitor=${1:-0}
+geometry=( $(herbstclient monitor_rect "$monitor") )
+if [ -z "$geometry" ] ;then
+    echo "Invalid monitor $monitor"
+    exit 1
+fi
+# geometry has the format: WxH+X+Y
+x=${geometry[0]}
+y=${geometry[1]}
+panel_width=${geometry[2]}
+panel_height=14
+font="-*-fixed-medium-*-*-*-10-*-*-*-*-*-*-*"
+#font="DejaVu Sans Mono:size=8"
+bgcolor=$(herbstclient get frame_border_normal_color)
+selbg=$(herbstclient get window_border_active_color)
+selfg='#101010'
+
+####
+# Try to find textwidth binary.
+# In e.g. Ubuntu, this is named dzen2-textwidth.
+if [ -e "$(which textwidth 2> /dev/null)" ] ; then
+    textwidth="textwidth";
+elif [ -e "$(which dzen2-textwidth 2> /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
+dzen2_version=$(dzen2 -v 2>&1 | head -n 1 | cut -d , -f 1|cut -d - -f 2)
+if [ -z "$dzen2_version" ] ; then
+    dzen2_svn="true"
+else
+    dzen2_svn=""
+fi
+
+function uniq_linebuffered() {
+    awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
+}
+
+herbstclient pad $monitor $panel_height
+{
+    # events:
+  # (mpc idleloop player | sed 's/^/mpd_/') &
+    (mpc idleloop player | cat) &
+  # mpc idleloop player &
+
+    while true; do echo 'tick'; sleep 5; done &
+
+    while true ; do
+        date +'date ^fg()%H^fg(#909090):^fg()%M^fg(#909090), %Y-%m-^fg()%d'
+        sleep 1 || break
+    done > >(uniq_linebuffered)  &
+
+    childpid=$!
+    herbstclient --idle
+    kill $childpid
+
+} 2> /dev/null | {
+    TAGS=( $(herbstclient tag_status $monitor) )
+    visible=true
+
+    date="^fg()--"
+    windowtitle=""
+
+    brightstatus="^fg()--"
+    batstatus="^fg()--"
+    thermstatus="^fg()--"
+    nowplaying="^fg()--"
+
+    while true ; do
+        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
+                echo -n "^ca(1,herbstclient focus_monitor $monitor && "'herbstclient use "'${i:1}'") '"${i:1} ^ca()"
+            else
+                echo -n " ${i:1} "
+            fi
+        done
+
+        echo -n "$separator"
+        echo -n "^bg()^fg() ${windowtitle//^/^^}"
+
+        S="$separator"
+
+        # small adjustments
+        right="$separator^bg() $brightstatus $S $thermstatus $S $batstatus $S $nowplaying $S $date $S"
+        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=300
+
+        echo -n "^pa($(($panel_width - $width)))$right"
+        echo
+
+        # wait for next event
+        read line || break
+        cmd=( $line )
+        # find out event origin
+        case "${cmd[0]}" in
+            tag*)
+                #echo "reseting tags" >&2
+                TAGS=( $(herbstclient tag_status $monitor) )
+                ;;
+            date)
+                #echo "reseting date" >&2
+                date="${cmd[@]:1}"
+                ;;
+            quit_panel)
+                exit
+                ;;
+            togglehidepanel)
+                echo "^togglehide()"
+                if $visible ; then
+                    visible=false
+                    herbstclient pad $monitor 0
+                else
+                    visible=true
+                    herbstclient pad $monitor $panel_height
+                fi
+                ;;
+            reload)
+                exit
+                ;;
+            focus_changed|window_title_changed)
+                windowtitle="${cmd[@]:2}"
+                ;;
+
+            brightness)
+                brightstatus="$(printf '^fg()%d^fg(#909090)%%' $(brightness-alter.sh '?'))"
+                ;;
+
+            tick)
+                batstatus="$( t='/sys/class/power_supply/BAT1/'
+                              curr=$(cat $t/charge_now)
+                              full=$(cat $t/charge_full)
+                              status=$(cat $t/status)
+                              percent=$(printf '100 * %d / %d\n' $curr $full | bc)
+
+                              if [ $status == Full ]; then
+                                printf '^fg(#909090)%s' $status
+                              else
+                                printf '^fg(#909090)%s: ^fg()%d%%' $status $percent
+                              fi )"
+
+                thermstatus="$( t='/sys/class/thermal/thermal_zone0'
+                                curr=$(cat $t/temp)
+                                degrees=$(printf '%d / 1000\n' $curr | bc)
+                                printf '^fg()%d^fg(#909090)C' $degrees )"
+                ;;
+
+            mpd_player|player)
+              # nowplaying="$(mpc current -f '^fg()[%artist% - ][%title%|%file%][ [%time%]]')"
+                nowplaying="$(mpc current -f '^fg()%artist% - %title%')"
+                ;;
+        esac
+        done
+} 2> /dev/null | dzen2 -w $panel_width -x $x -y $y -fn "$font" -h $panel_height \
+    -ta l -bg "$bgcolor" -fg '#efefef'
+
+