1#!/usr/bin/env bash
2
3# this is a simple config for herbstluftwm
4
5hc() {
6    herbstclient "$@"
7}
8
9hc emit_hook reload
10
11xsetroot -solid '#5A8E3A'
12
13# remove all existing keybindings
14hc keyunbind --all
15
16# keybindings
17# if you have a super key you will be much happier with Mod set to Mod4
18Mod=Mod1    # Use alt as the main modifier
19#Mod=Mod4   # Use the super key as the main modifier
20
21hc keybind $Mod-Shift-q quit
22hc keybind $Mod-Shift-r reload
23hc keybind $Mod-Shift-c close
24hc keybind $Mod-Return spawn "${TERMINAL:-xterm}" # use your $TERMINAL with xterm as fallback
25
26# basic movement in tiling and floating mode
27# focusing clients
28hc keybind $Mod-Left  focus left
29hc keybind $Mod-Down  focus down
30hc keybind $Mod-Up    focus up
31hc keybind $Mod-Right focus right
32hc keybind $Mod-h     focus left
33hc keybind $Mod-j     focus down
34hc keybind $Mod-k     focus up
35hc keybind $Mod-l     focus right
36
37# moving clients in tiling and floating mode
38hc keybind $Mod-Shift-Left  shift left
39hc keybind $Mod-Shift-Down  shift down
40hc keybind $Mod-Shift-Up    shift up
41hc keybind $Mod-Shift-Right shift right
42hc keybind $Mod-Shift-h     shift left
43hc keybind $Mod-Shift-j     shift down
44hc keybind $Mod-Shift-k     shift up
45hc keybind $Mod-Shift-l     shift right
46
47# splitting frames
48# create an empty frame at the specified direction
49hc keybind $Mod-u       split   bottom  0.5
50hc keybind $Mod-o       split   right   0.5
51# let the current frame explode into subframes
52hc keybind $Mod-Control-space split explode
53
54# resizing frames and floating clients
55resizestep=0.02
56hc keybind $Mod-Control-h       resize left +$resizestep
57hc keybind $Mod-Control-j       resize down +$resizestep
58hc keybind $Mod-Control-k       resize up +$resizestep
59hc keybind $Mod-Control-l       resize right +$resizestep
60hc keybind $Mod-Control-Left    resize left +$resizestep
61hc keybind $Mod-Control-Down    resize down +$resizestep
62hc keybind $Mod-Control-Up      resize up +$resizestep
63hc keybind $Mod-Control-Right   resize right +$resizestep
64
65# tags are 1..9
66
67hc rename default "1" || true
68for i in $(seq 1 9) ; do
69    hc add "${i}"
70    hc keybind "$Mod-$key" use_index "$i"
71    hc keybind "$Mod-Shift-$key" move_index "$i"
72done
73
74# cycle through tags
75hc keybind $Mod-period use_index +1 --skip-visible
76hc keybind $Mod-comma  use_index -1 --skip-visible
77
78# layouting
79hc keybind $Mod-r remove
80hc keybind $Mod-s floating toggle
81hc keybind $Mod-f fullscreen toggle
82hc keybind $Mod-Shift-f set_attr clients.focus.floating toggle
83hc keybind $Mod-Shift-m set_attr clients.focus.minimized true
84# restore all minimized windows of the focused tag
85hc keybind $Mod-Ctrl-m foreach CLIENT clients. \
86     sprintf MINATT "%c.minimized" CLIENT \
87     sprintf TAGATT "%c.tag" CLIENT and \
88       , compare MINATT "=" "true" \
89       , substitute FOCUS "tags.focus.name" compare TAGATT "=" FOCUS \
90       , set_attr MINATT false
91hc keybind $Mod-p pseudotile toggle
92# The following cycles through the available layouts within a frame, but skips
93# layouts, if the layout change wouldn't affect the actual window positions.
94# I.e. if there are two windows within a frame, the grid layout is skipped.
95hc keybind $Mod-space                                                           \
96            or , and . compare tags.focus.curframe_wcount = 2                   \
97                     . cycle_layout +1 vertical horizontal max vertical grid    \
98               , cycle_layout +1
99
100# mouse
101hc mouseunbind --all
102hc mousebind $Mod-Button1 move
103hc mousebind $Mod-Button2 zoom
104hc mousebind $Mod-Button3 resize
105
106# focus
107hc keybind $Mod-BackSpace   cycle_monitor
108hc keybind $Mod-Tab         cycle_all +1
109hc keybind $Mod-Shift-Tab   cycle_all -1
110hc keybind $Mod-c cycle
111hc keybind $Mod-i jumpto urgent
112
113# theme
114hc attr theme.tiling.reset 1
115hc attr theme.floating.reset 1
116hc set frame_border_active_color '#222222'
117hc set frame_border_normal_color '#101010'
118hc set frame_bg_normal_color '#565656'
119hc set frame_bg_active_color '#345F0C'
120hc set frame_border_width 1
121hc set always_show_frame on
122hc set frame_bg_transparent on
123hc set frame_transparent_width 5
124hc set frame_gap 4
125
126hc attr theme.title_height 15
127hc attr theme.title_font 'Dejavu Sans:pixelsize=12'  # example using Xft
128# hc attr theme.title_font '-*-fixed-medium-r-*-*-13-*-*-*-*-*-*-*'
129hc attr theme.padding_top 2  # space below the title's baseline (i.e. text depth)
130hc attr theme.active.color '#9fbc00'
131hc attr theme.normal.color '#454545'
132hc attr theme.urgent.color orange
133hc attr theme.inner_width 1
134hc attr theme.inner_color black
135hc attr theme.border_width 3
136hc attr theme.floating.border_width 4
137hc attr theme.floating.outer_width 1
138hc attr theme.floating.outer_color black
139hc attr theme.active.inner_color '#3E4A00'
140hc attr theme.active.outer_color '#3E4A00'
141hc attr theme.background_color '#141414'
142
143hc set window_gap 0
144hc set frame_padding 0
145hc set smart_window_surroundings off
146hc set smart_frame_surroundings on
147hc set mouse_recenter_gap 0
148
149# rules
150hc unrule -F
151#hc rule class=XTerm tag=3 # move all xterms to tag 3
152hc rule focus=on # normally focus new clients
153hc rule floatplacement=smart
154#hc rule focus=off # normally do not focus new clients
155# give focus to most common terminals
156#hc rule class~'(.*[Rr]xvt.*|.*[Tt]erm|Konsole)' focus=on
157hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on
158hc rule windowtype='_NET_WM_WINDOW_TYPE_DIALOG' focus=on
159hc rule windowtype~'_NET_WM_WINDOW_TYPE_(NOTIFICATION|DOCK|DESKTOP)' manage=off
160
161hc set tree_style '╾│ ├└╼─┐'
162
163# unlock, just to be sure
164hc unlock
165
166# do multi monitor setup here, e.g.:
167# hc set_monitors 1280x1024+0+0 1280x1024+1280+0
168# or simply:
169# hc detect_monitors
170
171# find the panel
172panel=~/.config/herbstluftwm/panel.sh
173[ -x "$panel" ] || panel=/etc/xdg/herbstluftwm/panel.sh
174for monitor in $(hc list_monitors | cut -d: -f1) ; do
175    # start it on each monitor
176    "$panel" "$monitor" &
177done
178