1 ;;; bandali-exwm.el --- bandali's EXWM configuration -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2018-2022 Amin Bandali
5 ;; Author: Amin Bandali <bandali@gnu.org>
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
23 ;; My EXWM setup. Makes good use of its simulation keys.
27 (add-to-list 'load-path
(b/lisp
"xelb"))
28 (add-to-list 'load-path
(b/lisp
"exwm"))
30 ;; (setq exwm-replace t)
31 ;; make class name the buffer name, truncating beyond 60 characters
32 (defun b/exwm-rename-buffer
()
34 (exwm-workspace-rename-buffer
35 (concat exwm-class-name
":"
36 (if (<= (length exwm-title
) 60) exwm-title
37 (concat (substring exwm-title
0 59) "...")))))
40 (add-hook 'exwm-update-class-hook
#'b
/exwm-rename-buffer
)
41 (add-hook 'exwm-update-title-hook
#'b
/exwm-rename-buffer
)
43 (require 'exwm-config
)
44 (add-hook 'exwm-init-hook
#'exwm-config--fix
/ido-buffer-window-other-frame
)
47 (defun b/exwm-ws-prev-index
()
48 "Return the index for the previous EXWM workspace, wrapping
50 (if (= exwm-workspace-current-index
0)
51 (1- exwm-workspace-number
)
52 (1- exwm-workspace-current-index
)))
54 (defun b/exwm-ws-next-index
()
55 "Return the index for the next EXWM workspace, wrapping
57 (if (= exwm-workspace-current-index
58 (1- exwm-workspace-number
))
60 (1+ exwm-workspace-current-index
)))
62 (defun b/exwm-ws-prev
()
63 "Switch to previous EXWM workspace, wrapping around if needed."
65 (exwm-workspace-switch-create
66 (b/exwm-ws-prev-index
)))
68 (defun b/exwm-ws-next
()
69 "Switch to next EXWM workspace, wrapping around if needed."
71 (exwm-workspace-switch-create
72 (b/exwm-ws-next-index
)))
74 ;; shorten 'C-c C-q' to 'C-q'
75 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
77 ;; scroll up/down/left/right on the echo area
78 (define-key minibuffer-inactive-mode-map
[mouse-4
] #'b
/exwm-ws-prev
)
79 (define-key minibuffer-inactive-mode-map
[mouse-5
] #'b
/exwm-ws-next
)
80 (define-key minibuffer-inactive-mode-map
[mouse-6
] #'b
/exwm-ws-prev
)
81 (define-key minibuffer-inactive-mode-map
[mouse-7
] #'b
/exwm-ws-next
)
83 (defvar b
/shifted-ws-names
84 '(0 \
) 1 \
! 2 \
@ 3 \
# 4 \$
85 5 \%
6 \^
7 \
& 8 \
* 9 \
()
86 "Mapping of shifted numbers on my keyboard.")
89 exwm-workspace-number
10
90 exwm-input-global-keys
91 `(([?\s-R
] . exwm-reset
)
92 ;; ([?\s-b] . exwm-workspace-switch-to-buffer)
93 ([?\s-
/] . exwm-workspace-switch
)
95 ([?\s-
\\] .
(lambda ()
97 (start-process-shell-command
98 "passmenu" nil
"passmenu --type")))
99 ([?\S-\s-\s
] .
(lambda (command)
101 (list (read-shell-command "➜ ")))
102 (start-process-shell-command
103 command nil command
)))
104 ([s-return
] .
(lambda ()
106 (start-process "" nil
"xterm")))
107 ([S-s-return
] .
(lambda ()
109 (start-process "" nil
"xterm"
110 "-name" "floating")))
111 ([?\C-\s-\s
] . counsel-linux-app
)
112 ([?\s-h
] . windmove-left
)
113 ([?\s-j
] . windmove-down
)
114 ([?\s-k
] . windmove-up
)
115 ([?\s-l
] . windmove-right
)
116 ([?\s-H
] . windmove-swap-states-left
)
117 ([?\s-J
] . windmove-swap-states-down
)
118 ([?\s-K
] . windmove-swap-states-up
)
119 ([?\s-L
] . windmove-swap-states-right
)
120 ([?\s-N ?d
] .
(lambda ()
123 "" nil
"dunstctl" "close")))
124 ([?\s-N ?D
] .
(lambda ()
127 "" nil
"dunstctl" "close-all")))
128 ([?\s-N ?h
] .
(lambda ()
131 "" nil
"dunstctl" "history-pop")))
132 ([?\s-N return
] .
(lambda ()
135 "" nil
"dunstctl" "context")))
136 ([?\M-\s-h
] . shrink-window-horizontally
)
137 ([?\M-\s-l
] . enlarge-window-horizontally
)
138 ([?\M-\s-k
] . shrink-window
)
139 ([?\M-\s-j
] . enlarge-window
)
140 ([?\s-\
[] . b
/exwm-ws-prev
)
141 ([?\s-\
]] . b
/exwm-ws-next
)
142 ([mode-line mouse-4
] . b
/exwm-ws-prev
) ; up
143 ([mode-line mouse-5
] . b
/exwm-ws-next
) ; down
144 ([mode-line mouse-6
] . b
/exwm-ws-prev
) ; left
145 ([mode-line mouse-7
] . b
/exwm-ws-next
) ; right
146 ([?\s-
{] .
(lambda ()
148 (exwm-workspace-move-window
149 (b/exwm-ws-prev-index
))))
150 ([?\s-
}] .
(lambda ()
152 (exwm-workspace-move-window
153 (b/exwm-ws-next-index
))))
154 ,@(mapcar (lambda (i)
155 `(,(kbd (format "s-%d" i
)) .
158 (exwm-workspace-switch-create ,i
))))
159 (number-sequence 0 (1- exwm-workspace-number
)))
162 `(,(kbd (format "s-%s"
163 (plist-get b
/shifted-ws-names i
)))
167 (exwm-workspace-move-window ,i
))))
168 (number-sequence 0 (1- exwm-workspace-number
)))
169 ([?\s-.
] . exwm-floating-toggle-floating
)
170 ([?\s-f
] . exwm-layout-toggle-fullscreen
)
171 ([?\s-W
] .
(lambda ()
173 (kill-buffer (current-buffer))))
174 ([?\s-Q
] .
(lambda ()
176 (exwm-manage--kill-client)))
177 ([?\s-
\'] .
(lambda ()
179 (start-process-shell-command
180 "dmneu-light" nil
"dmenu-light")))
181 ([?\s-\
;] . (lambda ()
183 (start-process-shell-command
184 "dmneu-pamixer" nil
"dmenu-pamixer")))
185 ([XF86AudioMute] . ; borken on my X200 :-(
188 (start-process "" nil "pamixer" "--toggle-mute")))
192 (start-process "" nil "pamixer" "--toggle-mute")))
193 ([\s-XF86Launch1] . ; toggle mic mute
197 "" nil "pamixer" "--default-source" "--toggle-mute")))
198 ([XF86AudioLowerVolume] .
202 "" nil "pamixer" "--allow-boost" "--decrease" "5")))
203 ([XF86AudioRaiseVolume] .
207 "" nil "pamixer" "--allow-boost" "--increase" "5")))
211 (start-process "" nil "mpc" "toggle")))
215 (start-process "" nil "mpc" "prev")))
219 (start-process "" nil "mpc" "next")))
220 ([XF86MonBrightnessDown] .
223 (start-process "" nil "light" "-U" "5")))
224 ([XF86MonBrightnessUp] .
227 (start-process "" nil "light" "-A" "5")))
231 (start-process "" nil "dm-tool" "lock")))
232 ([\s-XF86Back] . previous-buffer)
233 ([\s-XF86Forward] . next-buffer)))
235 ;; Line-editing shortcuts
237 exwm-input-simulation-keys
242 ([?\M-f] . [C-right])
250 ([?\C-k] . [S-end ?\C-x])
257 ([?\M-d] . [C-S-right ?\C-x])
258 ([?\M-\d] . [C-S-left ?\C-x])
267 ([?\C-/] . [?\C-z])))
269 (require 'exwm-manage)
271 exwm-manage-configurations
272 '(((equal exwm-instance-name "floating")
274 floating-mode-line nil)))
275 (add-hook 'exwm-manage-finish-hook
277 (when exwm-class-name
279 ((member exwm-class-name '("Abrowser" "IceCat" "Iceweasel"))
280 (exwm-input-set-local-simulation-keys
281 `(,@exwm-input-simulation-keys
282 ([?\C-\S-d] . [?\C-d]))))
283 ((member exwm-class-name '("XTerm" "Mate-terminal"))
284 (exwm-input-set-local-simulation-keys
285 '(([?\C-c ?\C-c] . [?\C-c])
286 ([?\C-c ?\C-u] . [?\C-u]))))
287 ((string= exwm-class-name "Zathura")
288 (exwm-input-set-local-simulation-keys
290 ([?\C-n] . [C-down]))))))))
292 (require 'exwm-randr)
294 exwm-randr-workspace-monitor-plist
296 1 "eDP-1" 2 "eDP-1" 3 "eDP-1"
297 4 "eDP-1" 5 "eDP-1" 6 "eDP-1"
298 7 "HDMI-1" 8 "HDMI-1" 9 "HDMI-1"))
300 ;; 'exwm-randr-screen-change-hook
302 ;; (start-process-shell-command
304 ;; "xrandr --output HDMI-1 --mode 1280x720 --above eDP-1 --auto")))
307 (require 'exwm-systemtray)
308 (exwm-systemtray-enable)
310 (add-to-list 'load-path (b/lisp "exwm-edit"))
313 (with-eval-after-load 'exwm-workspace
314 (setq exwm-workspace-show-all-buffers t)
321 " [%s]" (number-to-string
322 exwm-workspace-current-index)))))))
324 (with-eval-after-load 'exwm-layout
325 (setq exwm-layout-show-all-buffers t))
327 (provide 'bandali-exwm)
328 ;;; bandali-exwm.el ends here