1 ;;; bandali-exwm.el --- bandali's EXWM configuration -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2018-2021 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 (csetq ;; 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.")
89 (csetq 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-\s] . (lambda ()
97 ;; (start-process-shell-command
98 ;; "rofi" nil "rofi -show run")))
99 ([?\S-\s-\s
] .
(lambda (command) ; doesn't work in X windows
101 (list (read-shell-command "➜ ")))
102 (start-process-shell-command
103 command nil command
)))
104 ([s-return
] .
(lambda ()
106 (start-process "" nil
"urxvt")))
107 ([S-s-return
] .
(lambda ()
109 (start-process "" nil
"urxvt"
110 "-name" "floating")))
111 ([?\C-\s-\s
] . counsel-linux-app
)
112 ([?\M-\s-\s
] .
(lambda ()
114 (start-process-shell-command
115 "rofi-pass" nil
"rofi-pass")))
116 ([?\s-h
] . windmove-left
)
117 ([?\s-j
] . windmove-down
)
118 ([?\s-k
] . windmove-up
)
119 ([?\s-l
] . windmove-right
)
120 ([?\s-H
] . windmove-swap-states-left
)
121 ([?\s-J
] . windmove-swap-states-down
)
122 ([?\s-K
] . windmove-swap-states-up
)
123 ([?\s-L
] . windmove-swap-states-right
)
124 ([?\s-N ?d
] .
(lambda ()
127 "" nil
"dunstctl" "close")))
128 ([?\s-N ?D
] .
(lambda ()
131 "" nil
"dunstctl" "close-all")))
132 ([?\s-N ?h
] .
(lambda ()
135 "" nil
"dunstctl" "history-pop")))
136 ([?\s-N return
] .
(lambda ()
139 "" nil
"dunstctl" "context")))
140 ([?\M-\s-h
] . shrink-window-horizontally
)
141 ([?\M-\s-l
] . enlarge-window-horizontally
)
142 ([?\M-\s-k
] . shrink-window
)
143 ([?\M-\s-j
] . enlarge-window
)
144 ([?\s-\
[] . b
/exwm-ws-prev
)
145 ([?\s-\
]] . b
/exwm-ws-next
)
146 ([mode-line mouse-4
] . b
/exwm-ws-prev
) ; up
147 ([mode-line mouse-5
] . b
/exwm-ws-next
) ; down
148 ([mode-line mouse-6
] . b
/exwm-ws-prev
) ; left
149 ([mode-line mouse-7
] . b
/exwm-ws-next
) ; right
150 ([?\s-
{] .
(lambda ()
152 (exwm-workspace-move-window
153 (b/exwm-ws-prev-index
))))
154 ([?\s-
}] .
(lambda ()
156 (exwm-workspace-move-window
157 (b/exwm-ws-next-index
))))
158 ,@(mapcar (lambda (i)
159 `(,(kbd (format "s-%d" i
)) .
162 (exwm-workspace-switch-create ,i
))))
163 (number-sequence 0 (1- exwm-workspace-number
)))
166 `(,(kbd (format "s-%s"
167 (plist-get b
/shifted-ws-names i
)))
171 (exwm-workspace-move-window ,i
))))
172 (number-sequence 0 (1- exwm-workspace-number
)))
173 ([?\s-F
] . exwm-floating-toggle-floating
)
174 ([?\s-f
] . exwm-layout-toggle-fullscreen
)
175 ([?\s-W
] .
(lambda ()
177 (kill-buffer (current-buffer))))
178 ([?\s-Q
] .
(lambda ()
180 (exwm-manage--kill-client)))
181 ([?\s-
\'] .
(lambda ()
183 (start-process-shell-command
184 "rofi-light" nil
"rofi-light")))
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
236 (csetq exwm-input-simulation-keys
241 ([?\M-f] . [C-right])
249 ([?\C-k] . [S-end ?\C-x])
256 ([?\M-d] . [C-S-right ?\C-x])
257 ([?\M-\d] . [C-S-left ?\C-x])
264 ([?\C-g] . [escape])))
266 (require 'exwm-manage)
268 exwm-manage-configurations
269 '(((equal exwm-instance-name "floating")
271 floating-mode-line nil)))
272 (add-hook 'exwm-manage-finish-hook
274 (when exwm-class-name
276 ((member exwm-class-name '("Abrowser" "IceCat" "Iceweasel"))
277 (exwm-input-set-local-simulation-keys
278 `(,@exwm-input-simulation-keys
279 ([?\C-\S-d] . [?\C-d]))))
280 ((member exwm-class-name '("URxvt" "Mate-terminal"))
281 (exwm-input-set-local-simulation-keys
282 '(([?\C-c ?\C-c] . [?\C-c])
283 ([?\C-c ?\C-u] . [?\C-u]))))
284 ((string= exwm-class-name "Zathura")
285 (exwm-input-set-local-simulation-keys
287 ([?\C-n] . [C-down]))))))))
289 (require 'exwm-randr)
291 exwm-randr-workspace-monitor-plist
293 1 "eDP-1" 2 "eDP-1" 3 "eDP-1"
294 4 "eDP-1" 5 "eDP-1" 6 "eDP-1"
295 7 "HDMI-1" 8 "HDMI-1" 9 "HDMI-1"))
297 ;; 'exwm-randr-screen-change-hook
299 ;; (start-process-shell-command
301 ;; "xrandr --output HDMI-1 --mode 1280x720 --above eDP-1 --auto")))
304 (require 'exwm-systemtray)
305 (exwm-systemtray-enable)
307 (add-to-list 'load-path (b/lisp "exwm-edit"))
310 (provide 'bandali-exwm)
311 ;;; bandali-exwm.el ends here