Commit | Line | Data |
---|---|---|
4c05c418 AB |
1 | ;;; bandali-exwm.el --- bandali's EXWM configuration -*- lexical-binding: t; -*- |
2 | ||
3 | ;; Copyright (C) 2018-2020 Amin Bandali | |
4 | ||
5 | ;; Author: Amin Bandali <bandali@gnu.org> | |
6 | ;; Keywords: tools | |
7 | ||
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. | |
12 | ||
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. | |
17 | ||
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/>. | |
20 | ||
21 | ;;; Commentary: | |
22 | ||
23 | ;; My EXWM setup. Makes good use of its simulation keys. | |
24 | ||
25 | ;;; Code: | |
26 | ||
8b1a2f32 AB |
27 | (use-package exwm |
28 | :if b/exwm-p | |
29 | :demand | |
30 | :config | |
31 | ;; make class name the buffer name, truncating beyond 60 characters | |
32 | (defun b/exwm-rename-buffer () | |
33 | (interactive) | |
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) "..."))))) | |
38 | ;; Enable EXWM | |
39 | (exwm-enable) | |
40 | :hook ((exwm-update-class . b/exwm-rename-buffer) | |
41 | (exwm-update-title . b/exwm-rename-buffer))) | |
42 | ||
43 | (use-package exwm-config | |
44 | :demand | |
45 | :after exwm | |
46 | :hook (exwm-init . exwm-config--fix/ido-buffer-window-other-frame)) | |
47 | ||
48 | (use-package exwm-input | |
49 | :demand | |
50 | :after exwm | |
51 | :config | |
52 | (defun b/exwm-ws-prev-index () | |
53 | "Return the index for the previous EXWM workspace, wrapping | |
54 | around if needed." | |
55 | (if (= exwm-workspace-current-index 0) | |
56 | (1- exwm-workspace-number) | |
57 | (1- exwm-workspace-current-index))) | |
58 | ||
59 | (defun b/exwm-ws-next-index () | |
60 | "Return the index for the next EXWM workspace, wrapping | |
61 | around if needed." | |
62 | (if (= exwm-workspace-current-index | |
63 | (1- exwm-workspace-number)) | |
64 | 0 | |
65 | (1+ exwm-workspace-current-index))) | |
66 | ||
67 | ;; shorten 'C-c C-q' to 'C-q' | |
68 | (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key) | |
69 | ||
70 | (setq exwm-workspace-number 4 | |
71 | exwm-input-global-keys | |
72 | `(([?\s-R] . exwm-reset) | |
73 | ([?\s-\\] . exwm-workspace-switch) | |
74 | ([?\s-\s] . dmenu) | |
75 | ([?\S-\s-\s] . (lambda (command) | |
76 | (interactive | |
77 | (list (read-shell-command "➜ "))) | |
78 | (start-process-shell-command | |
79 | command nil command))) | |
80 | ([s-return] . (lambda () | |
81 | (interactive) | |
82 | (start-process "" nil "urxvt"))) | |
83 | ([?\C-\s-\s] . counsel-linux-app) | |
84 | ([?\M-\s-\s] . (lambda () | |
85 | (interactive) | |
86 | (start-process-shell-command | |
87 | "rofi-pass" nil "rofi-pass"))) | |
88 | ([?\s-h] . windmove-left) | |
89 | ([?\s-j] . windmove-down) | |
90 | ([?\s-k] . windmove-up) | |
91 | ([?\s-l] . windmove-right) | |
92 | ([?\s-H] . windmove-swap-states-left) | |
93 | ([?\s-J] . windmove-swap-states-down) | |
94 | ([?\s-K] . windmove-swap-states-up) | |
95 | ([?\s-L] . windmove-swap-states-right) | |
96 | ([?\M-\s-h] . shrink-window-horizontally) | |
97 | ([?\M-\s-l] . enlarge-window-horizontally) | |
98 | ([?\M-\s-k] . shrink-window) | |
99 | ([?\M-\s-j] . enlarge-window) | |
100 | ([?\s-\[] . (lambda () | |
101 | (interactive) | |
102 | (exwm-workspace-switch-create | |
103 | (b/exwm-ws-prev-index)))) | |
104 | ([?\s-\]] . (lambda () | |
105 | (interactive) | |
106 | (exwm-workspace-switch-create | |
107 | (b/exwm-ws-next-index)))) | |
108 | ([?\s-{] . (lambda () | |
109 | (interactive) | |
110 | (exwm-workspace-move-window | |
111 | (b/exwm-ws-prev-index)))) | |
112 | ([?\s-}] . (lambda () | |
113 | (interactive) | |
114 | (exwm-workspace-move-window | |
115 | (b/exwm-ws-next-index)))) | |
116 | ,@(mapcar (lambda (i) | |
117 | `(,(kbd (format "s-%d" i)) . | |
118 | (lambda () | |
119 | (interactive) | |
120 | (exwm-workspace-switch-create ,i)))) | |
121 | (number-sequence 0 (1- exwm-workspace-number))) | |
122 | ([?\s-t] . exwm-floating-toggle-floating) | |
123 | ([?\s-f] . exwm-layout-toggle-fullscreen) | |
124 | ([?\s-W] . (lambda () | |
125 | (interactive) | |
126 | (kill-buffer (current-buffer)))) | |
127 | ([?\s-Q] . (lambda () | |
128 | (interactive) | |
129 | (exwm-manage--kill-client))) | |
130 | ([?\s-\'] . (lambda () | |
131 | (interactive) | |
132 | (start-process-shell-command | |
133 | "rofi-light" nil "rofi-light"))) | |
134 | ([XF86AudioMute] . | |
135 | (lambda () | |
136 | (interactive) | |
137 | (start-process "" nil "amixer" "set" "'Master',0" "toggle"))) | |
138 | ([XF86AudioLowerVolume] . | |
139 | (lambda () | |
140 | (interactive) | |
141 | (start-process | |
142 | "" nil "amixer" "set" "'Master',0" "5%-"))) | |
143 | ([XF86AudioRaiseVolume] . | |
144 | (lambda () | |
145 | (interactive) | |
146 | (start-process | |
147 | "" nil "amixer" "set" "'Master',0" "5%+"))) | |
148 | ([XF86AudioPlay] . | |
149 | (lambda () | |
150 | (interactive) | |
151 | (start-process "" nil "mpc" "toggle"))) | |
152 | ([XF86AudioPrev] . | |
153 | (lambda () | |
154 | (interactive) | |
155 | (start-process "" nil "mpc" "prev"))) | |
156 | ([XF86AudioNext] . | |
157 | (lambda () | |
158 | (interactive) | |
159 | (start-process "" nil "mpc" "next"))) | |
160 | ([XF86ScreenSaver] . | |
161 | (lambda () | |
162 | (interactive) | |
163 | (start-process "" nil "dm-tool" "lock"))) | |
164 | ([\s-XF86Back] . previous-buffer) | |
165 | ([\s-XF86Forward] . next-buffer))) | |
166 | ||
167 | ;; Line-editing shortcuts | |
168 | (setq exwm-input-simulation-keys | |
169 | '(;; movement | |
170 | ([?\C-b] . [left]) | |
171 | ([?\M-b] . [C-left]) | |
172 | ([?\C-f] . [right]) | |
173 | ([?\M-f] . [C-right]) | |
174 | ([?\C-p] . [up]) | |
175 | ([?\C-n] . [down]) | |
176 | ([?\C-a] . [home]) | |
177 | ([?\C-e] . [end]) | |
178 | ([?\M-v] . [prior]) | |
179 | ([?\C-v] . [next]) | |
180 | ([?\C-d] . [delete]) | |
181 | ([?\C-k] . [S-end ?\C-x]) | |
182 | ([?\M-<] . C-home) | |
183 | ([?\M->] . C-end) | |
184 | ;; cut/copy/paste | |
185 | ([?\C-w] . [?\C-x]) | |
186 | ([?\M-w] . [?\C-c]) | |
187 | ([?\C-y] . [?\C-v]) | |
188 | ([?\M-d] . [C-S-right ?\C-x]) | |
189 | ([?\M-\d] . [C-S-left ?\C-x]) | |
190 | ;; window | |
191 | ([?\s-w] . [?\C-w]) | |
192 | ([?\s-q] . [?\C-q]) | |
193 | ;; misc | |
194 | ([?\C-s] . [?\C-f]) | |
195 | ([?\s-s] . [?\C-s]) | |
196 | ([?\C-g] . [escape])))) | |
197 | ||
198 | (use-package exwm-manage | |
199 | :demand | |
200 | :after exwm | |
201 | :hook | |
202 | (exwm-manage-finish . (lambda () | |
203 | (when exwm-class-name | |
204 | (cond | |
205 | ((string= exwm-class-name "IceCat") | |
206 | (exwm-input-set-local-simulation-keys | |
207 | `(,@exwm-input-simulation-keys | |
208 | ([?\C-\S-d] . [?\C-d])))) | |
209 | ((string= exwm-class-name "URxvt") | |
210 | (exwm-input-set-local-simulation-keys | |
211 | '(([?\C-c ?\C-c] . [?\C-c]) | |
212 | ([?\C-c ?\C-u] . [?\C-u])))) | |
213 | ((string= exwm-class-name "Zathura") | |
214 | (exwm-input-set-local-simulation-keys | |
215 | '(([?\C-p] . [C-up]) | |
216 | ([?\C-n] . [C-down]))))))))) | |
217 | ||
218 | (use-package exwm-randr | |
219 | :demand | |
220 | :after exwm | |
221 | :config | |
222 | (exwm-randr-enable) | |
223 | :custom | |
224 | (exwm-randr-workspace-monitor-plist '(1 "VGA-1"))) | |
225 | ||
226 | (use-package exwm-systemtray | |
227 | :demand | |
228 | :after exwm | |
229 | :config | |
230 | (exwm-systemtray-enable)) | |
231 | ||
232 | (use-package exwm-workspace) | |
233 | ||
234 | (use-package exwm-edit | |
235 | :demand | |
236 | :after exwm) | |
237 | ||
238 | (provide 'bandali-exwm) | |
4c05c418 | 239 | ;;; bandali-exwm.el ends here |