From ArchWiki
Revision as of 11:32, 20 November 2014 by Ypnos (talk | contribs) (remove stub. it is quite a comprehensive entry now.)
Jump to: navigation, search



Herbstluftwm can be installed with the package herbstluftwm or the AUR package herbstluftwm-git.

First steps

Read carefully herbstluftwm and herbstclient man pages in your favorite terminal emulator or online (herbstluftwm, herbstclient). Take your time to read through the whole documentation, they contain a lot of information from an explanation of the binary tree in which the layout is kept to config file options and possible values.



The configuration of herbstluftwm is updated on-the-fly by issuing herbstclient reload (See Commands section), or having a keybinding for the reload command. Autostart is called on each reload, therefore within autostart you typically unmap all existing configuration first.

Multi-Monitor Support

Herbstluftwm supports multiple monitors as a virtual concept; monitors in herbstluftwm do not have to match the real monitor configuration as reported by xrandr. It brings a lot of flexibility and gives the user more control over his/her monitor-arrangement. You can use herbstclient detect_monitors to automatically adapt to the physical setup. Otherwise, see the manpage on how to add, remove, resize and move monitors.


Herbstclient is a very powerful tool, as it provides you with full control over your window manager from the command line.



Scripts and Hooks

The main way to control herbstluftwm is though commands to herbstclient. Since herbstclient can be called from any script, you have great flexibility in controlling herbstluftwm this way. Furthermore, you can listen to window management events and react to them accordingly.

Script to switch to the next empty tag


ruby herbst-move.rb +1 full



And here is the script.


incr, type = ARGV

d = incr.to_i
if type == 'full'
  ch = '.'
  ch = ':'

len = array.length

i = (orig+d) % len
  array[i][0] == ch
  i = (i+d) % len

if i != orig
  system "herbstclient use_index #{i}"

Script to cycle though paddings (or other settings)



file1 = "/tmp/herbst-padding-1"
file2 = "/tmp/herbst-padding-2"

pad1 = 'pad 0 0 0 0 0'
pad2 = 'pad 0 0 20 0 200'
pad3 = 'pad 0 0 0 0 150'


if files == [false, false]  # 0 files
  system "herbstclient #{pad2}"
  system "touch #{file1}"
elsif files == [true, false]  # 1 file
  system "herbstclient #{pad1}"
  system "touch #{file2}"
else           # 2 files
  system "herbstclient #{pad3}"
  system "rm #{file1} #{file2}"

Script to change decoration per-tag

The following Perl script demonstrates how to use hooks to react to window management events. It can be called in autostart (with backgrounding).

# This script watches for tag changes and gives visual feedback

## Configuration (fill with your tag names)
my %colors = (
	main => '#DD0000',
	devel => '#13B8E0',
	write => '#96E013',
	admin => '#C713E0'

## Apply tag color
# Right now we change the active window's border color to the tag's color.
sub redecorate
	my ($foo, $activity) = @_;
	system("herbstclient", "set", "window_border_active_color",

## main routine
use v5.20;

# set up a pipe for reading hooks
open HOOKS, "herbstclient -i '(tag_changed|reload)'|"
	or die "can't fork: $!";
# process incoming messages
while (<HOOKS>) {
	for ($_) {
		redecorate(split(/\t/)) when /^tag_changed/;
		last OUTER when /^reload/; # quit on reload
close HOOKS or die "unfinished love story: $! $?"; # happens on hlwm crash

See also