blob: d9be901686a2889e82892d463646aa7c5490eb8c (
plain) (
blame)
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
(use-package exwm
:if b/exwm-p
:demand
:config
;; make class name the buffer name, truncating beyond 60 characters
(defun b/exwm-rename-buffer ()
(interactive)
(exwm-workspace-rename-buffer
(concat exwm-class-name ":"
(if (<= (length exwm-title) 60) exwm-title
(concat (substring exwm-title 0 59) "...")))))
;; Enable EXWM
(exwm-enable)
:hook ((exwm-update-class . b/exwm-rename-buffer)
(exwm-update-title . b/exwm-rename-buffer)))
(use-package exwm-config
:demand
:after exwm
:hook (exwm-init . exwm-config--fix/ido-buffer-window-other-frame))
(use-package exwm-input
:demand
:after exwm
:config
(defun b/exwm-ws-prev-index ()
"Return the index for the previous EXWM workspace, wrapping
around if needed."
(if (= exwm-workspace-current-index 0)
(1- exwm-workspace-number)
(1- exwm-workspace-current-index)))
(defun b/exwm-ws-next-index ()
"Return the index for the next EXWM workspace, wrapping
around if needed."
(if (= exwm-workspace-current-index
(1- exwm-workspace-number))
0
(1+ exwm-workspace-current-index)))
;; shorten 'C-c C-q' to 'C-q'
(define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key)
(setq exwm-workspace-number 4
exwm-input-global-keys
`(([?\s-R] . exwm-reset)
([?\s-\\] . exwm-workspace-switch)
([?\s-\s] . dmenu)
([?\S-\s-\s] . (lambda (command)
(interactive
(list (read-shell-command "➜ ")))
(start-process-shell-command
command nil command)))
([s-return] . (lambda ()
(interactive)
(start-process "" nil "urxvt")))
([?\C-\s-\s] . counsel-linux-app)
([?\M-\s-\s] . (lambda ()
(interactive)
(start-process-shell-command
"rofi-pass" nil "rofi-pass")))
([?\s-h] . windmove-left)
([?\s-j] . windmove-down)
([?\s-k] . windmove-up)
([?\s-l] . windmove-right)
([?\s-H] . windmove-swap-states-left)
([?\s-J] . windmove-swap-states-down)
([?\s-K] . windmove-swap-states-up)
([?\s-L] . windmove-swap-states-right)
([?\M-\s-h] . shrink-window-horizontally)
([?\M-\s-l] . enlarge-window-horizontally)
([?\M-\s-k] . shrink-window)
([?\M-\s-j] . enlarge-window)
([?\s-\[] . (lambda ()
(interactive)
(exwm-workspace-switch-create
(b/exwm-ws-prev-index))))
([?\s-\]] . (lambda ()
(interactive)
(exwm-workspace-switch-create
(b/exwm-ws-next-index))))
([?\s-{] . (lambda ()
(interactive)
(exwm-workspace-move-window
(b/exwm-ws-prev-index))))
([?\s-}] . (lambda ()
(interactive)
(exwm-workspace-move-window
(b/exwm-ws-next-index))))
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 (1- exwm-workspace-number)))
([?\s-t] . exwm-floating-toggle-floating)
([?\s-f] . exwm-layout-toggle-fullscreen)
([?\s-W] . (lambda ()
(interactive)
(kill-buffer (current-buffer))))
([?\s-Q] . (lambda ()
(interactive)
(exwm-manage--kill-client)))
([?\s-\'] . (lambda ()
(interactive)
(start-process-shell-command
"rofi-light" nil "rofi-light")))
([XF86AudioMute] .
(lambda ()
(interactive)
(start-process "" nil "amixer" "set" "'Master',0" "toggle")))
([XF86AudioLowerVolume] .
(lambda ()
(interactive)
(start-process
"" nil "amixer" "set" "'Master',0" "5%-")))
([XF86AudioRaiseVolume] .
(lambda ()
(interactive)
(start-process
"" nil "amixer" "set" "'Master',0" "5%+")))
([XF86AudioPlay] .
(lambda ()
(interactive)
(start-process "" nil "mpc" "toggle")))
([XF86AudioPrev] .
(lambda ()
(interactive)
(start-process "" nil "mpc" "prev")))
([XF86AudioNext] .
(lambda ()
(interactive)
(start-process "" nil "mpc" "next")))
([XF86ScreenSaver] .
(lambda ()
(interactive)
(start-process "" nil "dm-tool" "lock")))
([\s-XF86Back] . previous-buffer)
([\s-XF86Forward] . next-buffer)))
;; Line-editing shortcuts
(setq exwm-input-simulation-keys
'(;; movement
([?\C-b] . [left])
([?\M-b] . [C-left])
([?\C-f] . [right])
([?\M-f] . [C-right])
([?\C-p] . [up])
([?\C-n] . [down])
([?\C-a] . [home])
([?\C-e] . [end])
([?\M-v] . [prior])
([?\C-v] . [next])
([?\C-d] . [delete])
([?\C-k] . [S-end ?\C-x])
([?\M-<] . C-home)
([?\M->] . C-end)
;; cut/copy/paste
([?\C-w] . [?\C-x])
([?\M-w] . [?\C-c])
([?\C-y] . [?\C-v])
([?\M-d] . [C-S-right ?\C-x])
([?\M-\d] . [C-S-left ?\C-x])
;; window
([?\s-w] . [?\C-w])
([?\s-q] . [?\C-q])
;; misc
([?\C-s] . [?\C-f])
([?\s-s] . [?\C-s])
([?\C-g] . [escape]))))
(use-package exwm-manage
:demand
:after exwm
:hook
(exwm-manage-finish . (lambda ()
(when exwm-class-name
(cond
((string= exwm-class-name "IceCat")
(exwm-input-set-local-simulation-keys
`(,@exwm-input-simulation-keys
([?\C-\S-d] . [?\C-d]))))
((string= exwm-class-name "URxvt")
(exwm-input-set-local-simulation-keys
'(([?\C-c ?\C-c] . [?\C-c])
([?\C-c ?\C-u] . [?\C-u]))))
((string= exwm-class-name "Zathura")
(exwm-input-set-local-simulation-keys
'(([?\C-p] . [C-up])
([?\C-n] . [C-down])))))))))
(use-package exwm-randr
:demand
:after exwm
:config
(exwm-randr-enable)
:custom
(exwm-randr-workspace-monitor-plist '(1 "VGA-1")))
(use-package exwm-systemtray
:demand
:after exwm
:config
(exwm-systemtray-enable))
(use-package exwm-workspace)
(use-package exwm-edit
:demand
:after exwm)
(provide 'bandali-exwm)
|