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")))
131 (start-process "" nil "amixer" "set" "'Master',0" "toggle")))
132 ([XF86AudioLowerVolume] .
136 "" nil "amixer" "set" "'Master',0" "5%-")))
137 ([XF86AudioRaiseVolume] .
141 "" nil "amixer" "set" "'Master',0" "5%+")))
145 (start-process "" nil "mpc" "toggle")))
149 (start-process "" nil "mpc" "prev")))
153 (start-process "" nil "mpc" "next")))
157 (start-process "" nil "dm-tool" "lock")))
158 ([\s-XF86Back] . previous-buffer)
159 ([\s-XF86Forward] . next-buffer)))
161 ;; Line-editing shortcuts
162 (csetq exwm-input-simulation-keys
167 ([?\M-f] . [C-right])
175 ([?\C-k] . [S-end ?\C-x])
182 ([?\M-d] . [C-S-right ?\C-x])
183 ([?\M-\d] . [C-S-left ?\C-x])
190 ([?\C-g] . [escape])))
192 (require 'exwm-manage)
193 (add-hook 'exwm-manage-finish-hook
195 (when exwm-class-name
197 ((string= exwm-class-name "IceCat")
198 (exwm-input-set-local-simulation-keys
199 `(,@exwm-input-simulation-keys
200 ([?\C-\S-d] . [?\C-d]))))
201 ((string= exwm-class-name "URxvt")
202 (exwm-input-set-local-simulation-keys
203 '(([?\C-c ?\C-c] . [?\C-c])
204 ([?\C-c ?\C-u] . [?\C-u]))))
205 ((string= exwm-class-name "Zathura")
206 (exwm-input-set-local-simulation-keys
208 ([?\C-n] . [C-down]))))))))
210 (require 'exwm-randr)
212 (csetq exwm-randr-workspace-monitor-plist '(1 "VGA-1"))
214 (require 'exwm-systemtray)
215 (exwm-systemtray-enable)
217 (add-to-list 'load-path (b/lisp "exwm-edit"))
220 (provide 'bandali-exwm)
221 ;;; bandali-exwm.el ends here