My herbstluftwm configuration
CREATED:
UPDATED:
It's the best manual tile window manager I've used.
The default configuration is fine in most cases.
I added rules to make some firefox addons usable at my tiny netbook.
Here is my modified $HOME/.config/herbstluftwm/autostart:
#!/bin/bash
# this is a simple config for herbstluftwm
function hc() {
herbstclient "$@"
}
hc emit_hook reload
xsetroot -solid '#000000'
#feh --bg-scale /home/cb/.config/herbstluftwm/wallpaper.jpg
# keybindings
Mod=Mod4
hc keybind $Mod-Shift-q quit
hc keybind $Mod-Shift-r reload
hc keybind $Mod-Shift-c close
hc keybind $Mod-Return spawn terminator
hc keybind $Mod-x spawn dmenu_run
hc keybind $Mod-q spawn scrot -e 'mkdir -p ~/screenshot;mv $f ~/screenshot/'
# tags
TAG_NAMES=( {1..4} )
TAG_KEYS=( {1..4} 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 "${TAG_NAMES[$i]}"
hc keybind "$Mod-Shift-$key" move "${TAG_NAMES[$i]}"
fi
done
# layouting
hc keybind $Mod-r remove
hc keybind $Mod-space cycle_layout 1
hc keybind $Mod-Shift-s split vertical 0.5
hc keybind $Mod-s split horizontal 0.5
hc keybind $Mod-o floating toggle
hc keybind $Mod-f fullscreen toggle
hc keybind $Mod-p pseudotile toggle
# resizing
RESIZESTEP=0.05
hc keybind $Mod-Control-h resize left +$RESIZESTEP
hc keybind $Mod-Control-j resize down +$RESIZESTEP
hc keybind $Mod-Control-k resize up +$RESIZESTEP
hc keybind $Mod-Control-l resize right +$RESIZESTEP
# mouse
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-j focus down
hc keybind $Mod-k focus up
hc keybind $Mod-l focus right
hc keybind $Mod-Shift-h shift left
hc keybind $Mod-Shift-j shift down
hc keybind $Mod-Shift-k shift up
hc keybind $Mod-Shift-l shift right
# colors
hc set frame_border_active_color '#49351D'
hc set frame_border_normal_color '#73532D'
hc set frame_bg_normal_color '#BD9768'
hc set frame_bg_active_color '#BD8541'
hc set frame_border_width 0
hc set window_border_width 0
hc set window_border_normal_color '#AE8451'
hc set window_border_active_color '#F6FF00'
# rules
hc unrule -F
#hc rule class=XTerm tag=3 # move all xterms to tag 3
hc rule focus=on # 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
hc rule instance=xv class=MPlayer fullscreen=on
#firefox dialog should be fullscreen, useful for my tiny eeepc
hc rule instance="Dialog" class="Firefox" fullscreen=on #delicious bookmark
hc rule instance="Aup" class="Firefox" fullscreen=on #autoproxy
hc rule instance="Abp" class="Firefox" fullscreen=on #adblock plus
#view the image in fullscreen
#hc rule instance=feh class=feh fullscreen=on #feh has some bug
#autorun
hc spawn ~/.config/herbstluftwm/panel.sh
hc spawn parcellite -nd #use parcellite -p/-c to see the content
xprop is useful for writing "hc rule". Please man herbstclient
.
panel.sh is from the official package. It will display a panel at the top of the screen.
Here is my $HOME/.config/herbstluftwm/panel.sh (modified for display batttery rate):
#!/bin/bash
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]}
width=${geometry[2]}
height=16
font="-*-fixed-medium-*-*-*-12-*-*-*-*-*-*-*"
bgcolor='#3E2600'
function uniq_linebuffered() {
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
}
herbstclient pad $monitor $height
{
# events:
#mpc idleloop player &
while true ; do
date +'date ^fg(#efefef)%H:%M^fg(#909090), %Y-%m-^fg(#efefef)%d'
sleep 1 || break
done > >(uniq_linebuffered) &
childpid=$!
herbstclient --idle
kill $childpid
} 2> /dev/null | {
TAGS=( $(herbstclient tag_status $monitor) )
date=""
while true ; do
bordercolor="#26221C"
hintcolor="#573500"
separator="^fg(#141414)^ro(1x$height)^fg()"
# draw tags
for i in "${TAGS[@]}" ; do
case ${i:0:1} in
'#')
echo -n "^bg(#9fbc00)^fg(#141414)"
;;
'+')
echo -n "^bg(#9CA668)^fg(#141414)"
;;
':')
echo -n "^bg(#6A4100)^fg(#141414)"
;;
'!')
echo -n "^bg(#FF0675)^fg(#141414)"
;;
*)
echo -n "^bg()^fg()"
;;
esac
echo -n "^ca(1,herbstclient focus_monitor $monitor && "'herbstclient use "'${i:1}'") '"${i:1} ^ca()"
echo -n "$separator"
done
echo -n "^bg()^p(_CENTER)"
# small adjustments
battery=$(expr $(expr $(cat /sys/class/power_supply/BAT*/charge_now) \* 100) / $(cat /sys/class/power_supply/BAT*/charge_full))
if [ "$battery" = "/" ] ;then
right="$separator^bg($hintcolor) $date $separator"
else
right="$separator^bg($hintcolor) $battery% $date $separator"
fi
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 "^p(_RIGHT)^p(-$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
;;
reload)
exit
;;
#player)
# ;;
esac
done
} 2> /dev/null | dzen2 -w $width -x $x -y $y -fn "$font" -h $height \
-ta l -bg "$bgcolor" -fg '#efefef'
UPDATE: I use https://i3wm.org/ now