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