aboutsummaryrefslogtreecommitdiffstats
path: root/xbindkeys/.xbindkeysrc.scm
blob: 07453f36334b1cc0293c3b42c04bb51a8c24158b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
;; -*- mode: scheme; -*-
(define modkey 'mod4)

(define (reset-top-level-binding)
  "Reset the keybindings to the top-level ones."
  (ungrab-all-keys)
  (remove-all-keys)
  (first-binding)
  (grab-all-keys))

(define (first-binding)
  "First binding"
  ;; These are dangerous keybindings, they could be very annoying if they're
  ;; accidentally pressed, so using Shift here to make it a little less easy to
  ;; do this is a good idea.
  (xbindkey `(,modkey q) "shutdown-rofi")
  (xbindkey `(,modkey shift r) "herbstclient reload")

  ;; Usually I close the applications I use through a menu or keybinding inside
  ;; the application, but not all applications offer this. Sometimes need to
  ;; tell the window manager to do so.
  (xbindkey `(,modkey k) "herbstclient close")

  ;; Normally I try to have frames set-up the way I like them programmatically,
  ;; not manually, but sometimes I need to do it manually anyway and remove them
  ;; afterwards.
  (xbindkey `(,modkey mod1 k) "herbstclient remove")

  ;; Always spawn an instance of kitty.
  (xbindkey `(,modkey Return) "herbstclient spawn kitty")
  ;; Switch to a running instance of URxvt, Hyper, or kitty or start one.
  (xbindkey `(,modkey t) "herbstclient spawn hlwm-run-or-raise \"\\(URxvt\\|Hyper\\|kitty\\)\" kitty")
  ;; Switch to a running instance of Conceror, Firefox, Chromium, Nyxt, or
  ;; qutebrowser or start one.
  (xbindkey `(,modkey b) "herbstclient spawn hlwm-run-or-raise \"\\(Conkeror\\|[Ff]irefox\\|Chromium\\|Nyxt\\|qutebrowser\\)\" firefox")
  ;; Switch to a running instance of Emacs, or create an Emacs client frame.
  (xbindkey `(,modkey e) "herbstclient spawn hlwm-run-or-raise Emacs emacsclient --create-frame")
  ;; Lock the screen with C-M-l.
  (xbindkey '(control mod1 l) "herbstclient spawn i3lock")
  ;; Swap visible tags
  (xbindkey `(,modkey x) "herbstclient spawn hlwm-switch-tags")

  ;; Since I use the colemak keyboard layout, hjkl doesn't make much sense. I
  ;; use bnpf instead since that is what I'm used to using in Emacs. I try to
  ;; use my run-or-raise script as much as I can, and have the layouts set-up
  ;; correctly already, but sometimes I still need to move around, resize and
  ;; move clients.
  (xbindkey `(,modkey shift b) "herbstclient shift left")
  (xbindkey `(,modkey shift n) "herbstclient shift down")
  (xbindkey `(,modkey shift p) "herbstclient shift up")
  (xbindkey `(,modkey shift f) "herbstclient shift right")
  (xbindkey `(,modkey control b) "herbstclient resize left +0.05")
  (xbindkey `(,modkey control n) "herbstclient resize down +0.05")
  (xbindkey `(,modkey control p) "herbstclient resize up +0.05")
  (xbindkey `(,modkey control f) "herbstclient resize right +0.05")

  ;; I usually try to have my layouts set-up programmatically, but this isn't
  ;; always possible or practical.
  (xbindkey `(,modkey shift underscore) "herbstclient split bottom 0.5")
  (xbindkey `(,modkey shift bar) "herbstclient split right 0.5")

  ;; Switching tags by number (key) isn't always practical, sometimes switching
  ;; to next/previous tag is easiest.
  (xbindkey `(,modkey period) "herbstclient use_index +1 --skip-visible")
  (xbindkey `(,modkey comma) "herbstclient use_index -1 --skip-visible")

  ;; Games and sometimes other applications don't always like being forced into
  ;; a strangely sized box, floating mode helps.
  (xbindkey `(,modkey shift control f) "herbstclient floating toggle")

  ;; Playing games in fullscreen mode can end badly by having the game spread
  ;; across both monitors. Also watching a twitch stream with lots of text is
  ;; best in fullscreen.
  (xbindkey `(,modkey f) "herbstclient cycle_layout 1 vertical max")
  (xbindkey `(,modkey m) "herbstclient fullscreen toggle")
  (xbindkey `(,modkey p) "herbstclient pseudotile toggle")

  ;; The following cycles through the available layouts within a frame, but
  ;; skips layouts, if the layout change wouldn't affect the actual window
  ;; positions. I.e. if there are two windows within a frame, the grid layout is
  ;; skipped.
  (xbindkey `(,modkey space) "herbstclient or , and . compare tags.focus.curframe_wcount = 2 . cycle_layout +1 vertical horizontal max vertical grid , cycle_layout +1")

  ;; focus
  (xbindkey `(,modkey BackSpace) "herbstclient cycle_monitor")

  ;; Use u because i is already used by by navigation commands.
  (xbindkey `(,modkey u) "herbstclient jumpto urgent")

  ;; Add some media key bindings for MPD.
  (xbindkey '(XF86AudioPlay) "herbstclient spawn mpc toggle")
  (xbindkey '(XF86AudioNext) "herbstclient spawn mpc next")
  (xbindkey '(XF86AudioPrev) "herbstclient spawn mpc prev")

  (xbindkey-function `(,modkey c) move-bindings)
  (xbindkey-function `(,modkey s) screenshot-bindings)
  (xbindkey `(,modkey bracketleft) "herbstclient use_index 0")
  (xbindkey `(,modkey shift bracketleft) "herbstclient use_index 1")
  (xbindkey `(,modkey shift bracketright) "herbstclient use_index 2")
  (xbindkey `(,modkey shift "9") "herbstclient use_index 3")
  (xbindkey `(,modkey equal) "herbstclient use_index 4")
  (xbindkey `(,modkey shift "8") "herbstclient use_index 5")
  (xbindkey `(,modkey shift "0") "herbstclient use_index 6")
  (xbindkey `(,modkey shift equal) "herbstclient use_index 7")
  (xbindkey `(,modkey bracketright) "herbstclient use_index 8")
  (xbindkey `(,modkey shift "1") "herbstclient use_index 9")
  (xbindkey `(,modkey r) "herbstclient spawn rofi -modi drun -show drun -config /home/chelys/.config/rofi/rofi.rasi")
  (xbindkey `(,modkey w) "herbstclient spawn rofi -show window -window-command \"/home/chelys/usr/bin/hlwm-switch-to-window {window}\" -config /home/chelys/.config/rofi/windows.rasi"))

(define (move-bindings)
  "Second bind"
  (ungrab-all-keys)
  (remove-all-keys)
  (xbindkey "1" "herbstclient move_index 0")
  (xbindkey-function '(release "1") reset-top-level-binding)
  (xbindkey "2" "herbstclient move_index 1")
  (xbindkey-function '(release "2") reset-top-level-binding)
  (xbindkey "3" "herbstclient move_index 2")
  (xbindkey-function '(release "3") reset-top-level-binding)
  (xbindkey "4" "herbstclient move_index 3")
  (xbindkey-function '(release "4") reset-top-level-binding)
  (xbindkey "5" "herbstclient move_index 4")
  (xbindkey-function '(release "5") reset-top-level-binding)
  (xbindkey "6" "herbstclient move_index 5")
  (xbindkey-function '(release "6") reset-top-level-binding)
  (xbindkey "7" "herbstclient move_index 6")
  (xbindkey-function '(release "7") reset-top-level-binding)
  (xbindkey "8" "herbstclient move_index 7")
  (xbindkey-function '(release "8") reset-top-level-binding)
  (xbindkey "9" "herbstclient move_index 8")
  (xbindkey-function '(release "9") reset-top-level-binding)
  (xbindkey "0" "herbstclient move_index 9")
  (xbindkey-function '(release "0") reset-top-level-binding)
  (xbindkey-function '(control g) reset-top-level-binding)
  (xbindkey-function '(Return) reset-top-level-binding)
  (xbindkey-function '(Escape) reset-top-level-binding)
  (grab-all-keys))

(define (screenshot-bindings)
  "Bindings for taking screenshots"
  (ungrab-all-keys)
  (remove-all-keys)
  (xbindkey "f" "flameshot full ~/pictures/screenshots/")
  (xbindkey-function '(release f) reset-top-level-binding)
  (xbindkey "c" "flameshot gui")
  (xbindkey-function '(release c) reset-top-level-binding)
  (xbindkey-function '(control g) reset-top-level-binding)
  (xbindkey-function '(Return) reset-top-level-binding)
  (xbindkey-function '(Escape) reset-top-level-binding)
  (grab-all-keys))

(first-binding)