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 exwm-workspace-show-all-buffers t
)
32 ;; make class name the buffer name, truncating beyond 60 characters
33 (defun b/exwm-rename-buffer
()
35 (exwm-workspace-rename-buffer
36 (concat exwm-class-name
":"
37 (if (<= (length exwm-title
) 60) exwm-title
38 (concat (substring exwm-title
0 59) "...")))))
41 (add-hook 'exwm-update-class-hook
#'b
/exwm-rename-buffer
)
42 (add-hook 'exwm-update-title-hook
#'b
/exwm-rename-buffer
)
44 (require 'exwm-config
)
45 (add-hook 'exwm-init-hook
#'exwm-config--fix
/ido-buffer-window-other-frame
)
48 (defun b/exwm-ws-prev-index
()
49 "Return the index for the previous EXWM workspace, wrapping
51 (if (= exwm-workspace-current-index
0)
52 (1- exwm-workspace-number
)
53 (1- exwm-workspace-current-index
)))
55 (defun b/exwm-ws-next-index
()
56 "Return the index for the next EXWM workspace, wrapping
58 (if (= exwm-workspace-current-index
59 (1- exwm-workspace-number
))
61 (1+ exwm-workspace-current-index
)))
63 (defun b/exwm-ws-prev
()
64 "Switch to previous EXWM workspace, wrapping around if needed."
66 (exwm-workspace-switch-create
67 (b/exwm-ws-prev-index
)))
69 (defun b/exwm-ws-next
()
70 "Switch to next EXWM workspace, wrapping around if needed."
72 (exwm-workspace-switch-create
73 (b/exwm-ws-next-index
)))
75 ;; shorten 'C-c C-q' to 'C-q'
76 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
78 ;; scroll up/down/left/right on the echo area
79 (define-key minibuffer-inactive-mode-map
[mouse-4
] #'b
/exwm-ws-prev
)
80 (define-key minibuffer-inactive-mode-map
[mouse-5
] #'b
/exwm-ws-next
)
81 (define-key minibuffer-inactive-mode-map
[mouse-6
] #'b
/exwm-ws-prev
)
82 (define-key minibuffer-inactive-mode-map
[mouse-7
] #'b
/exwm-ws-next
)
84 (defvar b
/shifted-ws-names
85 '(0 \
) 1 \
! 2 \
@ 3 \
# 4 \$
86 5 \%
6 \^
7 \
& 8 \
* 9 \
()
87 "Mapping of shifted numbers on my keyboard.")
90 exwm-workspace-number
10
91 exwm-input-global-keys
92 `(([?\s-R
] . exwm-reset
)
93 ([?\s-b
] . exwm-workspace-switch-to-buffer
)
94 ([?\s-
\\] . exwm-workspace-switch
)
96 ;; ([?\s-\s] . (lambda ()
98 ;; (start-process-shell-command
99 ;; "rofi" nil "rofi -show run")))
100 ([?\S-\s-\s
] .
(lambda (command) ; doesn't work in X windows
102 (list (read-shell-command "➜ ")))
103 (start-process-shell-command
104 command nil command
)))
105 ([s-return
] .
(lambda ()
107 (start-process "" nil
"urxvt")))
108 ([S-s-return
] .
(lambda ()
110 (start-process "" nil
"urxvt"
111 "-name" "floating")))
112 ([?\C-\s-\s
] . counsel-linux-app
)
113 ([?\M-\s-\s
] .
(lambda ()
115 (start-process-shell-command
116 "rofi-pass" nil
"rofi-pass")))
117 ([?\s-h
] . windmove-left
)
118 ([?\s-j
] . windmove-down
)
119 ([?\s-k
] . windmove-up
)
120 ([?\s-l
] . windmove-right
)
121 ([?\s-H
] . windmove-swap-states-left
)
122 ([?\s-J
] . windmove-swap-states-down
)
123 ([?\s-K
] . windmove-swap-states-up
)
124 ([?\s-L
] . windmove-swap-states-right
)
125 ([?\s-N ?d
] .
(lambda ()
128 "" nil
"dunstctl" "close")))
129 ([?\s-N ?D
] .
(lambda ()
132 "" nil
"dunstctl" "close-all")))
133 ([?\s-N ?h
] .
(lambda ()
136 "" nil
"dunstctl" "history-pop")))
137 ([?\s-N return
] .
(lambda ()
140 "" nil
"dunstctl" "context")))
141 ([?\M-\s-h
] . shrink-window-horizontally
)
142 ([?\M-\s-l
] . enlarge-window-horizontally
)
143 ([?\M-\s-k
] . shrink-window
)
144 ([?\M-\s-j
] . enlarge-window
)
145 ([?\s-\
[] . b
/exwm-ws-prev
)
146 ([?\s-\
]] . b
/exwm-ws-next
)
147 ([mode-line mouse-4
] . b
/exwm-ws-prev
) ; up
148 ([mode-line mouse-5
] . b
/exwm-ws-next
) ; down
149 ([mode-line mouse-6
] . b
/exwm-ws-prev
) ; left
150 ([mode-line mouse-7
] . b
/exwm-ws-next
) ; right
151 ([?\s-
{] .
(lambda ()
153 (exwm-workspace-move-window
154 (b/exwm-ws-prev-index
))))
155 ([?\s-
}] .
(lambda ()
157 (exwm-workspace-move-window
158 (b/exwm-ws-next-index
))))
159 ,@(mapcar (lambda (i)
160 `(,(kbd (format "s-%d" i
)) .
163 (exwm-workspace-switch-create ,i
))))
164 (number-sequence 0 (1- exwm-workspace-number
)))
167 `(,(kbd (format "s-%s"
168 (plist-get b
/shifted-ws-names i
)))
172 (exwm-workspace-move-window ,i
))))
173 (number-sequence 0 (1- exwm-workspace-number
)))
174 ([?\s-F
] . exwm-floating-toggle-floating
)
175 ([?\s-f
] . exwm-layout-toggle-fullscreen
)
176 ([?\s-W
] .
(lambda ()
178 (kill-buffer (current-buffer))))
179 ([?\s-Q
] .
(lambda ()
181 (exwm-manage--kill-client)))
182 ([?\s-
\'] .
(lambda ()
184 (start-process-shell-command
185 "rofi-light" nil
"rofi-light")))
186 ([XF86AudioMute] . ; borken on my X200 :-(
189 (start-process "" nil "pamixer" "--toggle-mute")))
193 (start-process "" nil "pamixer" "--toggle-mute")))
194 ([\s-XF86Launch1] . ; toggle mic mute
198 "" nil "pamixer" "--default-source" "--toggle-mute")))
199 ([XF86AudioLowerVolume] .
203 "" nil "pamixer" "--allow-boost" "--decrease" "5")))
204 ([XF86AudioRaiseVolume] .
208 "" nil "pamixer" "--allow-boost" "--increase" "5")))
212 (start-process "" nil "mpc" "toggle")))
216 (start-process "" nil "mpc" "prev")))
220 (start-process "" nil "mpc" "next")))
221 ([XF86MonBrightnessDown] .
224 (start-process "" nil "light" "-U" "5")))
225 ([XF86MonBrightnessUp] .
228 (start-process "" nil "light" "-A" "5")))
232 (start-process "" nil "dm-tool" "lock")))
233 ([\s-XF86Back] . previous-buffer)
234 ([\s-XF86Forward] . next-buffer)))
236 ;; Line-editing shortcuts
238 exwm-input-simulation-keys
243 ([?\M-f] . [C-right])
251 ([?\C-k] . [S-end ?\C-x])
258 ([?\M-d] . [C-S-right ?\C-x])
259 ([?\M-\d] . [C-S-left ?\C-x])
266 ([?\C-g] . [escape])))
268 (require 'exwm-manage)
270 exwm-manage-configurations
271 '(((equal exwm-instance-name "floating")
273 floating-mode-line nil)))
274 (add-hook 'exwm-manage-finish-hook
276 (when exwm-class-name
278 ((member exwm-class-name '("Abrowser" "IceCat" "Iceweasel"))
279 (exwm-input-set-local-simulation-keys
280 `(,@exwm-input-simulation-keys
281 ([?\C-\S-d] . [?\C-d]))))
282 ((member exwm-class-name '("URxvt" "Mate-terminal"))
283 (exwm-input-set-local-simulation-keys
284 '(([?\C-c ?\C-c] . [?\C-c])
285 ([?\C-c ?\C-u] . [?\C-u]))))
286 ((string= exwm-class-name "Zathura")
287 (exwm-input-set-local-simulation-keys
289 ([?\C-n] . [C-down]))))))))
291 (require 'exwm-randr)
293 exwm-randr-workspace-monitor-plist
295 1 "eDP-1" 2 "eDP-1" 3 "eDP-1"
296 4 "eDP-1" 5 "eDP-1" 6 "eDP-1"
297 7 "HDMI-1" 8 "HDMI-1" 9 "HDMI-1"))
299 ;; 'exwm-randr-screen-change-hook
301 ;; (start-process-shell-command
303 ;; "xrandr --output HDMI-1 --mode 1280x720 --above eDP-1 --auto")))
306 (require 'exwm-systemtray)
307 (exwm-systemtray-enable)
309 (add-to-list 'load-path (b/lisp "exwm-edit"))
312 (provide 'bandali-exwm)
313 ;;; bandali-exwm.el ends here