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.
27 (add-to-list 'load-path
(b/lisp
"xelb"))
28 (add-to-list 'load-path
(b/lisp
"exwm"))
30 ;; make class name the buffer name, truncating beyond 60 characters
31 (defun b/exwm-rename-buffer
()
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) "...")))))
39 (add-hook 'exwm-update-class-hook
#'b
/exwm-rename-buffer
)
40 (add-hook 'exwm-update-title-hook
#'b
/exwm-rename-buffer
)
42 (require 'exwm-config
)
43 (add-hook 'exwm-init-hook
#'exwm-config--fix
/ido-buffer-window-other-frame
)
46 (defun b/exwm-ws-prev-index
()
47 "Return the index for the previous EXWM workspace, wrapping
49 (if (= exwm-workspace-current-index
0)
50 (1- exwm-workspace-number
)
51 (1- exwm-workspace-current-index
)))
53 (defun b/exwm-ws-next-index
()
54 "Return the index for the next EXWM workspace, wrapping
56 (if (= exwm-workspace-current-index
57 (1- exwm-workspace-number
))
59 (1+ exwm-workspace-current-index
)))
61 ;; shorten 'C-c C-q' to 'C-q'
62 (define-key exwm-mode-map
[?\C-q
] #'exwm-input-send-next-key
)
64 (csetq exwm-workspace-number
4
65 exwm-input-global-keys
66 `(([?\s-R
] . exwm-reset
)
67 ([?\s-
\\] . exwm-workspace-switch
)
69 ([?\S-\s-\s
] .
(lambda (command)
71 (list (read-shell-command "➜ ")))
72 (start-process-shell-command
73 command nil command
)))
74 ([s-return
] .
(lambda ()
76 (start-process "" nil
"urxvt")))
77 ([?\C-\s-\s
] . counsel-linux-app
)
78 ([?\M-\s-\s
] .
(lambda ()
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 ()
96 (exwm-workspace-switch-create
97 (b/exwm-ws-prev-index
))))
98 ([?\s-\
]] .
(lambda ()
100 (exwm-workspace-switch-create
101 (b/exwm-ws-next-index
))))
102 ([?\s-
{] .
(lambda ()
104 (exwm-workspace-move-window
105 (b/exwm-ws-prev-index
))))
106 ([?\s-
}] .
(lambda ()
108 (exwm-workspace-move-window
109 (b/exwm-ws-next-index
))))
110 ,@(mapcar (lambda (i)
111 `(,(kbd (format "s-%d" i
)) .
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 ()
120 (kill-buffer (current-buffer))))
121 ([?\s-Q
] .
(lambda ()
123 (exwm-manage--kill-client)))
124 ([?\s-
\'] .
(lambda ()
126 (start-process-shell-command
127 "rofi-light" nil
"rofi-light")))
128 ([XF86AudioMute] . ; borken on my X200 :-(
131 (start-process "" nil "pamixer" "--toggle-mute")))
135 (start-process "" nil "pamixer" "--toggle-mute")))
136 ([\s-XF86Launch1] . ; toggle mic mute
140 "" nil "pamixer" "--default-source" "--toggle-mute")))
141 ([XF86AudioLowerVolume] .
145 "" nil "pamixer" "--allow-boost" "--decrease" "5")))
146 ([XF86AudioRaiseVolume] .
150 "" nil "pamixer" "--allow-boost" "--increase" "5")))
154 (start-process "" nil "mpc" "toggle")))
158 (start-process "" nil "mpc" "prev")))
162 (start-process "" nil "mpc" "next")))
166 (start-process "" nil "dm-tool" "lock")))
167 ([\s-XF86Back] . previous-buffer)
168 ([\s-XF86Forward] . next-buffer)))
170 ;; Line-editing shortcuts
171 (csetq exwm-input-simulation-keys
176 ([?\M-f] . [C-right])
184 ([?\C-k] . [S-end ?\C-x])
191 ([?\M-d] . [C-S-right ?\C-x])
192 ([?\M-\d] . [C-S-left ?\C-x])
199 ([?\C-g] . [escape])))
201 (require 'exwm-manage)
202 (add-hook 'exwm-manage-finish-hook
204 (when exwm-class-name
206 ((string= exwm-class-name "IceCat")
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
217 ([?\C-n] . [C-down]))))))))
219 (require 'exwm-randr)
221 (csetq exwm-randr-workspace-monitor-plist '(1 "VGA-1"))
223 (require 'exwm-systemtray)
224 (exwm-systemtray-enable)
226 (add-to-list 'load-path (b/lisp "exwm-edit"))
229 (provide 'bandali-exwm)
230 ;;; bandali-exwm.el ends here