1 ;;; bandali-exwm.el --- bandali's EXWM configuration -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2018-2020 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.
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 :hook
((exwm-update-class . b
/exwm-rename-buffer
)
41 (exwm-update-title . b
/exwm-rename-buffer
)))
43 (use-package exwm-config
46 :hook
(exwm-init . exwm-config--fix
/ido-buffer-window-other-frame
))
48 (use-package exwm-input
52 (defun b/exwm-ws-prev-index
()
53 "Return the index for the previous EXWM workspace, wrapping
55 (if (= exwm-workspace-current-index
0)
56 (1- exwm-workspace-number
)
57 (1- exwm-workspace-current-index
)))
59 (defun b/exwm-ws-next-index
()
60 "Return the index for the next EXWM workspace, wrapping
62 (if (= exwm-workspace-current-index
63 (1- exwm-workspace-number
))
65 (1+ exwm-workspace-current-index
)))
67 ;; shorten 'C-c C-q' to 'C-q'
68 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
70 (setq exwm-workspace-number
4
71 exwm-input-global-keys
72 `(([?\s-R
] . exwm-reset
)
73 ([?\s-
\\] . exwm-workspace-switch
)
75 ([?\S-\s-\s
] .
(lambda (command)
77 (list (read-shell-command "➜ ")))
78 (start-process-shell-command
79 command nil command
)))
80 ([s-return
] .
(lambda ()
82 (start-process "" nil
"urxvt")))
83 ([?\C-\s-\s
] . counsel-linux-app
)
84 ([?\M-\s-\s
] .
(lambda ()
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 ()
102 (exwm-workspace-switch-create
103 (b/exwm-ws-prev-index
))))
104 ([?\s-\
]] .
(lambda ()
106 (exwm-workspace-switch-create
107 (b/exwm-ws-next-index
))))
108 ([?\s-
{] .
(lambda ()
110 (exwm-workspace-move-window
111 (b/exwm-ws-prev-index
))))
112 ([?\s-
}] .
(lambda ()
114 (exwm-workspace-move-window
115 (b/exwm-ws-next-index
))))
116 ,@(mapcar (lambda (i)
117 `(,(kbd (format "s-%d" i
)) .
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 ()
126 (kill-buffer (current-buffer))))
127 ([?\s-Q
] .
(lambda ()
129 (exwm-manage--kill-client)))
130 ([?\s-
\'] .
(lambda ()
132 (start-process-shell-command
133 "rofi-light" nil
"rofi-light")))
137 (start-process "" nil "amixer" "set" "'Master',0" "toggle")))
138 ([XF86AudioLowerVolume] .
142 "" nil "amixer" "set" "'Master',0" "5%-")))
143 ([XF86AudioRaiseVolume] .
147 "" nil "amixer" "set" "'Master',0" "5%+")))
151 (start-process "" nil "mpc" "toggle")))
155 (start-process "" nil "mpc" "prev")))
159 (start-process "" nil "mpc" "next")))
163 (start-process "" nil "dm-tool" "lock")))
164 ([\s-XF86Back] . previous-buffer)
165 ([\s-XF86Forward] . next-buffer)))
167 ;; Line-editing shortcuts
168 (setq exwm-input-simulation-keys
173 ([?\M-f] . [C-right])
181 ([?\C-k] . [S-end ?\C-x])
188 ([?\M-d] . [C-S-right ?\C-x])
189 ([?\M-\d] . [C-S-left ?\C-x])
196 ([?\C-g] . [escape]))))
198 (use-package exwm-manage
202 (exwm-manage-finish . (lambda ()
203 (when exwm-class-name
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
216 ([?\C-n] . [C-down])))))))))
218 (use-package exwm-randr
224 (exwm-randr-workspace-monitor-plist '(1 "VGA-1")))
226 (use-package exwm-systemtray
230 (exwm-systemtray-enable))
232 (use-package exwm-workspace)
234 (use-package exwm-edit
238 (provide 'bandali-exwm)
239 ;;; bandali-exwm.el ends here