]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - herbstluftwm/autostart
herbstluftwm: Add basic configuration file.
[config/dotfiles.git] / herbstluftwm / autostart
1 #!/bin/sh
2
3 # Herbstluftm configuration file.
4
5 # Copyright (C) 2014  Simon Ruderich
6 #
7 # This file is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This file is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this file.  If not, see <http://www.gnu.org/licenses/>.
19
20
21 set -e
22
23 # Log all output to catch errors in the configuration file.
24 logfile="$HOME/.config/herbstluftwm/log"
25 exec >"$logfile" 2>&1
26
27
28 hc() {
29     herbstclient "$@"
30 }
31
32 # Tell all clients the configuration file was reloaded. Should be the first
33 # command in the autostart file.
34 hc emit_hook reload
35
36
37 # KEY BINDINGS
38
39 # Modifier used for all herbstluftwm key bindings.
40 mod=Mod4
41
42 # Remove all existing key bindings.
43 hc keyunbind --all
44
45 # Basic key bindings.
46 hc keybind $mod-Shift-Return spawn urxvt
47 hc keybind $mod-Shift-c close
48 hc keybind $mod-Shift-r reload
49 hc keybind $mod-Shift-q quit
50 # Lock the screen. The sleep is necessary to allow xtrlock to grab the
51 # keyboard input.
52 hc keybind $mod-z spawn sh -c 'sleep 1 && exec xtrlock'
53
54 # Tag key bindings. Create tags 1 to 9 with bindings to switch and move
55 # windows to them.
56 hc rename default 1 2>/dev/null || true
57 for i in `seq 1 9`; do
58     hc add "$i"
59     hc keybind "$mod-$i" use "$i"
60     hc keybind "$mod-Shift-$i" move "$i"
61 done
62 # Switch to last active tag.
63 hc keybind $mod-b use_previous
64
65 # Layouting key bindings.
66 hc keybind $mod-space cycle_layout 1 horizontal max # toggle these layouts
67 hc keybind $mod-u split vertical   0.5
68 hc keybind $mod-o split horizontal 0.5
69 hc keybind $mod-r remove                            # remove a split
70 # Change window state.
71 hc keybind $mod-f fullscreen toggle
72
73 # Focus key bindings.
74 hc keybind $mod-h focus left
75 hc keybind $mod-j focus down
76 hc keybind $mod-k focus up
77 hc keybind $mod-l focus right
78 # Move windows.
79 hc keybind $mod-Shift-h shift left
80 hc keybind $mod-Shift-j shift down
81 hc keybind $mod-Shift-k shift up
82 hc keybind $mod-Shift-l shift right
83
84
85 # MOUSE BINDINGS
86
87 # Remove all existing key bindings.
88 hc mouseunbind --all
89
90
91 # WINDOW and FRAME SETTINGS
92
93 # No border for frames, only for windows.
94 hc set frame_border_width  0
95 hc set window_border_width 1
96 # No gaps between frames or windows.
97 hc set frame_gap  0
98 hc set window_gap 0
99 # Inactive window borders are black, almost invisible on my black screen.
100 # Active window borders are dark red.
101 hc set window_border_normal_color '#000000'
102 hc set window_border_active_color '#990000'
103 # Transparent background for empty frames.
104 hc set frame_bg_transparent 1
105
106 # Use vertical layout for windows in frames per default.
107 hc set default_frame_layout 1 # vertical
108
109
110 # LAYOUT
111
112 # Run only on startup, not when reloading the config. Thanks to The-Compiler
113 # in #herbstluftwm on Freenode (2014-01-10 16:26 CET) for the idea to use
114 # environment variables.
115 if ! hc getenv HLWMRC_LOADED >/dev/null; then
116     hc setenv HLWMRC_LOADED 1
117
118     # Setup my layout: Vertical split with my main terminal window in the top
119     # frame, secondary windows in the bottom frame.
120     hc split vertical 0.5
121 fi
122
123
124 # RULES
125
126 # Remove all existing rules.
127 hc unrule --all
128
129 # * Do not focus new clients (default).
130 # * Don't allow clients to toggle fullscreen via EWMH.
131 # * Move new windows to the frame at the bottom of the screen.
132 hc rule focus=off \
133         ewmhrequests=off \
134         index=1
135
136
137 # After everything is done, allow redrawing of the windows.
138 hc unlock
139
140
141 # $1: timeout
142 notify() {
143     sed 's/\^/^^/g' | dzen2 -fg blue -bg yellow -y 15 -h 30 -p "$@"
144 }
145
146 if test -s "$logfile"; then
147     echo "hlwm: errors in autostart, check log '$logfile'" | notify 3
148 else
149     # To notify me if set -e has terminated the script.
150     echo 'hlwm restarted' | notify 1
151     rm "$logfile"
152 fi