Topic: Herbstluftwm thread? - Herbstluftwm thread!

I'm using hlwm as my default wm since two months and I'm really happy with it. When I first installed it, I was totally new to manual tiling but I picked it up quite fast, as hlwm's default keybindings are really intuitive for vim-users and you get used to the look and feel in no time... Anyway I thought I'd make a thread to share configs with other users (I hope there are some here wink) and provide help for beginners.

You can get Herbstluftwm and some documentation here: http://wwwcip.cs.fau.de/~re06huxa/herbstluftwm/

Short Introduction:
- Herbstluftwm is a manual tiling window manger, the layout is based on frames, which can be split up into subframes and those can be split up again and so on. Each frame can contain one or more clients and can be resized, added and removed freely.
- It's minimalistic and very lightweight: All it gives you is total control over your clients and and a tool to interact with it (herbstclient)
- It uses a bash script as the config file
- The dump/load feature is another cool thing, it dumps the layout of your current tag in a format, you can use to load it at startup or whenever you feel like it.
- It's somewhat early in development, so it still lacks some feature and there are a few bugs (although I only experienced   two crashes since I'm using it and the bug responsible for those got fixed the day after.)


So here is my config, based on the default/example one:

#!/bin/bash

# this is an simple config for herbstluftwm

function hc() {
    herbstclient "$@"
}

# autostart daemons'n'stuff
nitrogen --restore &
#xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
xbindkeys &
udiskie &
dzenconky.sh; dzendate.sh
twmnd &

#add padding for dzen2
hc pad 0 14 0 0 0

# keybindings
Mod=Mod4
hc keybind $Mod-q quit
hc keybind $Mod-Shift-r reload
hc keybind $Mod-x close
hc keybind $Mod-Return spawn urxvt

# tags
hc rename default 1 || true
for i in {1..9} ; do
    hc add "$i"
    hc keybind "$Mod-$i" use "$i"
    hc keybind "$Mod-Shift-$i" move "$i"
done

# layouting
hc keybind $Mod-r remove
hc keybind $Mod-space cycle_layout 1
hc keybind $Mod-u split vertical 0.5
hc keybind $Mod-o split horizontal 0.5
hc keybind $Mod-s floating toggle

# mouse
hc mousebind $Mod-Button1 move
hc mousebind $Mod-Button3 resize
hc mousebind $Mod-Button2 zoom

# 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

# 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

#dmenu
hc keybind $Mod-p spawn dmenu_run  -fn -*-terminus-medium-*-*-*-12-*-*-*-*-*-* -nb rgb:00/00/00 -nf rgb:CC/CC/CC -sb rgb:CC/CC/CC -sf rgb:33/33/33

# colors
hc set frame_border_active_color '#000000'
hc set frame_border_normal_color '#2B2B2B'
hc set frame_bg_normal_color '#CCCCCC'
hc set frame_bg_active_color '#666666' 
hc set frame_border_width 1
hc set window_border_width 1
hc set window_border_normal_color '#000000' 
hc set window_border_active_color '#CCCCCC' 

#settings
hc floating 3 on
hc set snap_distance 7
hc set snap_gap 3
hc set window_gap 0
hc set frame_bg_transparent 1
hc set focus_follows_mouse 1
hc set focus_follows_shift 1
hc set tree_style  "╾│ ├└╼─┐"

# load layout
hc load "(split horizontal:0.399800:0 (split vertical:0.250000:1 (clients vertical:0 0x2e00006) (split vertical:0.500000:1 (clients vertical:0 0x3000006) (clients vertical:0 0x2c00006))) (split vertical:0.750000:0 (clients vertical:0 0x2800006) (clients vertical:0 0x3200006)))"

#autostart apps
if [ ! $(pidof mpd) ]; then     
    mpd
fi
hc spawn urxvt
hc spawn urxvt
hc spawn urxvt
hc spawn urxvt -e centerim
hc spawn urxvt -e ranger

Here's a screenshot of my usual setup on tag 1
http://ompldr.org/tYWl0dQ

Last edited by Doomicide (2011-09-25 13:43:29)

“From each according to his faculties; to each according to his needs”

Re: Herbstluftwm thread? - Herbstluftwm thread!

Due to the overwhelming resonse this thread got (HA!) I decided to post some scripts I made:

1. This two scripts give you a scrotwm-like behaviour when switching tags (They only work with numbered tags, but it should be easy enough to change that:

Switch to previous tag:

#!/bin/bash

tagstat=$(herbstclient tag_status)

function checkbusy()
{
    case "$tagstat" in
        *':'$prevtag*)
            busy=1
        ;;
        *)
            busy=2
        ;;
    esac
}

# get current tag
for t in {1..9} ; do
    case "$tagstat" in
           *"#$t"*)
                curtag=$t;;
    esac
done

# determine if previous tag is busy
### uncomment this for scrotwm-like behaviour (only switch to busy tags)###
if [[ "$tagstat" == *':'* ]]; then
    busy=2
    prevtag=$curtag
    while [ $busy != 1 ] && (( 1 <= $prevtag )); do
        prevtag=$(($prevtag-1))
        checkbusy
    done
    herbstclient use $prevtag
else
    echo "lol"
    exit
fi

# change to previous tag 
### comment this for scrotwm-like behaviour (only switch to busy tags)###
#    prevtag=$(($curtag-1))
#    herbstclient use  $prevtag

and to the next one:

#!/bin/bash

tagstat=$(herbstclient tag_status)

function checkbusy()
{
    case "$tagstat" in
        *':'$nextag*)
            busy=1
        ;;
        *)
            busy=2
        ;;
    esac
}

# get current tag
for t in {1..9} ; do
    case "$tagstat" in
           *"#$t"*)
                curtag=$t;;
    esac
done

# determine if previous tag is busy
### uncomment this for scrotwm-like behaviour (only switch to busy tags)###
if [[ "$tagstat" == *':'* ]]; then
    busy=2
    nextag=$curtag
    while [ $busy != 1 ] && (( 9  >= $nextag  )); do
        nextag=$(($nextag+1))
        checkbusy
    done
    herbstclient use $nextag
else
    exit
fi


# change to next tag
### comment this for scrotwm-like behaviour (only switch to busy tags)###
#    nextag=$(($curtag+1))
#    herbstclient use  $nextag

Now put them in ~/bin and something like this in your autostart file:

hc keybind $Mod-Right spawn nextag
hc keybind $Mod-Left spawn prevtag

--

Plus here's an example of what you can do with herbstclient's new idle command:
(Heavily inspired by the panel.sh that comes with herbstluftwm)

#!/bin/bash

## dzen stuff
FG='#728651'
BG='black'
FONT='-*-terminus-medium-*-*-*-12-*-*-*-*-*-*'

function uniq_linebuffered() {
awk '$0 != l { print ; l=$0 ; fflush(); }' "$@"
}

(
while true ; do
        date +'date %a %d/%m/%y %T'
        mpcshow="$(mpc status | grep -) $(mpc status | cat -n | grep -E ^*2 | awk {'print $4'})"
        echo "mpc $mpcshow"
        sleep 1 || break
done | uniq_linebuffered &

herbstclient --idle &
)|(
TAG=$(herbstclient list_monitors | cut -d ' ' -f 5 | tr -d [:punct:])
date=""
mpcshow=""
while true; do
    echo -e " ^fg(\#CCCCCC):^fg()^fg(#865C51)$TAG^fg()^fg(#CCCCCC):^fg() $date  ^fg(#516086)$mpcshow^fg()"
    read line || break
    cmd=( $line )
    case "$cmd[0]" in
        date*)
                    #echo "reseting date" >&2
            date="${cmd[@]:1}"
            ;;
        tag*)
            #echo "reseting tag" >&2
            TAG=$(herbstclient list_monitors | cut -d ' ' -f 5 | tr -d [:punct:])
            ;;
        mpc*)
            mpcshow="${cmd[@]:1}"
            ;;
    esac
done
)|dzen2 -ta l -y 0 -x 0 -w 670 -fg $FG -bg $BG -fn $FONT &

Last edited by Doomicide (2011-10-07 09:35:23)

“From each according to his faculties; to each according to his needs”

Re: Herbstluftwm thread? - Herbstluftwm thread!

Sorry Doom ... I was busy during the first half of last week and overseas during the rest.
I'll give it a try in future. Probably not this week, but soon.

Thanks for sharing, btw. Always appreciated. smile

Last edited by gutterslob (2011-10-03 17:19:53)

Point & Squirt

Re: Herbstluftwm thread? - Herbstluftwm thread!

I have the feeling that there are more tiling WM than floating ones on the market, and they are all based on each other. But this one definitly has the best name of all of them.

I'm so meta, even this acronym

Re: Herbstluftwm thread? - Herbstluftwm thread!

@ gutterslob: no problem wink
@ Awebb: Yeah, if it hadn't been for the name I'd most certainly never tried it

“From each according to his faculties; to each according to his needs”

Re: Herbstluftwm thread? - Herbstluftwm thread!

Awebb wrote:

I have the feeling that there are more tiling WM than floating ones on the market, and they are all based on each other. But this one definitly has the best name of all of them.

.. and it is hard for beginners to find the difference between them. The documentation of Herbstluftwm explains some of the mechanisms behind the X, that's very interesting for me because now I do understand what a tiling window manager does, how the algorithms work.

My Blog | Recent post: You are who you are. Accept yourself.
Carpe diem? Too mainstream. Carpe Noctem!

Re: Herbstluftwm thread? - Herbstluftwm thread!

I just discovered ninjaaron's herbstluftwm thread on the arch forums and he posted some really cool hlwm scripts there, so I thought I'd share the link.

Last edited by Doomicide (2011-10-20 16:12:37)

“From each according to his faculties; to each according to his needs”

Re: Herbstluftwm thread? - Herbstluftwm thread!

I'm not sure what bar this WM uses, but does it happen to have a tray?

Re: Herbstluftwm thread? - Herbstluftwm thread!

@Doom
Heh!! ... I figured ninjaaron would start that thread sooner or later.
I think I was the one who first linked him to this thread, which probably got him started on his own stuff for herbstluftwm.
Anyways, props to the both of you. smile

Point & Squirt

Re: Herbstluftwm thread? - Herbstluftwm thread!

Hey, so I've decided to give this WM a go.... anyone know how I could get it configured to look like this screenshot:
http://wwwcip.cs.fau.de/~re06huxa/scree … cons-1.png

So I'm guessing the panel up top is.... dzen? The one at the bottom is conky.. but most of all I want to know what the colour/width settings are for the frames and windows. Looks very nice!

Re: Herbstluftwm thread? - Herbstluftwm thread!

Hey guys I guess it's time for my config smile

dotshare has all my configs. I combined doom's next & prev tag scripts into one, called seektag. I also got the colors from xdefs (using code from crshd on dotshare) and I made a little script to open a new split and move the current window to it. cool

Leave the gun. Take the cannoli.

Re: Herbstluftwm thread? - Herbstluftwm thread!

Which version of herbstluftwm are you using? I think since 0.3 my scripts next/prevtag are obsolete as the use_index command now does exactly the same wink (except for switching only to busy tags, but it should be alot easier to write a bash-script that does that, now that use_index is available. I'd generally recommend you to use the git-repo, as there are changes ~every week and it's stable anyhow. The opensplit-script is nice, as I'm used to ratpoison's behaviour which is similiar, ty smile

“From each according to his faculties; to each according to his needs”

Re: Herbstluftwm thread? - Herbstluftwm thread!

^ Oh yeah I have the use_index command; I saw that I had it after I wrote the seektag.sh.... I guess I should get around to changing it tongue

Although...if I did that it'd use hc to cycle through each one as it went, as opposed to this script which checks each one before it cycles. AFAIK it's actually faster? I haven't checked it though.

thanks about the opensplit!

Leave the gun. Take the cannoli.

Re: Herbstluftwm thread? - Herbstluftwm thread!

Okay, I want it to look as close as possible to dwm/awesome, but with the manual tiling. I've never used dzen and I've got no idea how to get herbstluft started other than having it actually open up.

hmm any help?

Re: Herbstluftwm thread? - Herbstluftwm thread!

thevdude wrote:

Okay, I want it to look as close as possible to dwm/awesome, but with the manual tiling. I've never used dzen and I've got no idea how to get herbstluft started other than having it actually open up.

hmm any help?

If you really just need a very basic guide to getting started, you could check out my review in the 30 WMs thread, especially the links at the end.

The herbstluftwm home page has good documention, and "man herbstluftwm" and "man herbstclient" are very useful. Also study the herbstluftwm autostart file (it's just a big bash script).

Last edited by 2ManyDogs (2012-04-26 02:11:25)

Re: Herbstluftwm thread? - Herbstluftwm thread!

I've got it all pretty much done, just have to set up a few autostart things big_smile

http://i.imgur.com/e3OE7.png

big_smile exactly what I've been wanting.