]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - herbstluftwm/autostart
herbstluftwm: Add mapping $mod-s to swap top and bottom frame.
[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
24 hc() {
25     herbstclient "$@"
26 }
27
28 # Tell all clients the configuration file was reloaded. Should be the first
29 # command in the autostart file.
30 hc emit_hook reload
31
32
33 # KEY BINDINGS
34
35 # Use Super (= "Windows") key as modifier which is used for all herbstluftwm
36 # key bindings.
37 mod=Mod4
38
39 # Remove all existing key bindings.
40 hc keyunbind --all
41
42 # Basic key bindings.
43 hc keybind $mod-Shift-Return spawn urxvt
44 hc keybind $mod-Shift-c close
45 hc keybind $mod-q reload
46 hc keybind $mod-Shift-q quit
47 # Lock the screen. The sleep is necessary to allow xtrlock to grab the
48 # keyboard input.
49 hc keybind $mod-z spawn sh -c 'sleep 1 && exec xtrlock'
50
51 # Tag key bindings. Create tags 1 to 9 with bindings to switch and move
52 # windows to them.
53 hc rename default 1 2>/dev/null || true
54 for i in `seq 1 9`; do
55     hc add "$i"
56     hc keybind "$mod-$i" use "$i"
57     hc keybind "$mod-Shift-$i" move "$i"
58 done
59 # Switch to last active tag.
60 hc keybind $mod-b use_previous
61
62 # Layouting key bindings.
63 hc keybind $mod-space cycle_layout 1 horizontal max # toggle these layouts
64 hc keybind $mod-u split vertical   0.5
65 hc keybind $mod-o split horizontal 0.5
66 hc keybind $mod-r remove                            # remove a split
67 # Change window state.
68 hc keybind $mod-f fullscreen toggle
69
70 # Focus key bindings.
71 hc keybind $mod-h focus left
72 hc keybind $mod-j focus down
73 hc keybind $mod-k focus up
74 hc keybind $mod-l focus right
75 # Move windows.
76 hc keybind $mod-Shift-h shift left
77 hc keybind $mod-Shift-j shift down
78 hc keybind $mod-Shift-k shift up
79 hc keybind $mod-Shift-l shift right
80 # Swap top and bottom frame (only works with two frames).
81 hc keybind $mod-s chain , lock , rotate , rotate , unlock
82
83
84 # MOUSE BINDINGS
85
86 # Remove all existing key bindings.
87 hc mouseunbind --all
88
89
90 # WINDOW and FRAME SETTINGS
91
92 # No border for frames, only for windows.
93 hc set frame_border_width  0
94 hc set window_border_width 1
95 # No gaps between frames or windows.
96 hc set frame_gap  0
97 hc set window_gap 0
98 # Inactive window borders are black, almost invisible on my black screen.
99 # Active window borders are dark red.
100 hc set window_border_normal_color '#000000'
101 hc set window_border_active_color '#990000'
102 # Transparent background for empty frames.
103 hc set frame_bg_transparent 1
104
105 # Use vertical layout for windows in frames per default.
106 hc set default_frame_layout 1 # vertical
107
108
109 # LAYOUT
110
111 # Run only on startup, not when reloading the config. Thanks to The-Compiler
112 # in #herbstluftwm on Freenode (2014-01-10 16:26 CET) for the idea to use
113 # environment variables.
114 if ! hc getenv HLWMRC_LOADED >/dev/null; then
115     hc setenv HLWMRC_LOADED 1
116
117     # Setup my layout: Vertical split with my main terminal window in the top
118     # frame, secondary windows in the bottom frame.
119     hc split vertical 0.5
120 fi
121
122
123 # RULES
124
125 # Remove all existing rules.
126 hc unrule --all
127
128 # * Do not focus new clients (default).
129 # * Don't allow clients to toggle fullscreen via EWMH.
130 # * Move new windows to the frame at the bottom of the screen.
131 hc rule focus=off \
132         ewmhrequests=off \
133         index=1
134
135
136 # After everything is done, allow redrawing of the windows.
137 hc unlock
138
139
140 # $1: timeout
141 notify() {
142     sed 's/\^/^^/g' | dzen2 -fg blue -bg yellow -y 15 -h 30 -p "$@"
143 }
144
145 # To notify me if set -e has terminated the script (then this part won't get
146 # executed).
147 echo 'hlwm restarted' | notify 1