emacs/linux-load/exwm-config.el
1	(require 'exwm)
2 (require 'ido)
3
4 (define-obsolete-function-alias 'exwm-config-default
5 #'exwm-config-example "27.1")
6
7 (defun exwm-config-spw ()
8 "Default configuration of EXWM."
9 ;; Set the initial workspace number.
10 (unless (get 'exwm-workspace-number 'saved-value)
11 (setq exwm-workspace-number 4))
12 ;; Make class name the buffer name
13 (add-hook 'exwm-update-class-hook
14 (lambda ()
15 (exwm-workspace-rename-buffer exwm-class-name)))
16 ;; Global keybindings.
17 (unless (get 'exwm-input-global-keys 'saved-value)
18 (setq exwm-input-global-keys
19 `(
20 ;; 's-r': Reset (to line-mode).
21 ([?\s-r] . exwm-reset)
22 ;; 's-w': Switch workspace.
23 ([?\s-w] . exwm-workspace-switch)
24 ;; 's-&': Launch application.
25 ([?\s-&] . (lambda (command)
26 (interactive (list (read-shell-command "$ ")))
27 (start-process-shell-command command nil command)))
28 ;; 's-N': Switch to certain workspace.
29 ,@(mapcar (lambda (i)
30 `(,(kbd (format "s-%d" i)) .
31 (lambda ()
32 (interactive)
33 (exwm-workspace-switch-create ,i))))
34 (number-sequence 0 9)))))
35 ;; Line-editing shortcuts
36 (unless (get 'exwm-input-simulation-keys 'saved-value)
37 (setq exwm-input-simulation-keys
38 '(([?\C-b] . [left])
39 ([?\C-f] . [right])
40 ([?\C-p] . [up])
41 ([?\C-n] . [down])
42 ([?\C-a] . [home])
43 ([?\C-e] . [end])
44 ([?\M-v] . [prior])
45 ([?\C-v] . [next])
46 ([?\C-d] . [delete])
47 ([?\C-k] . [S-end delete]))))
48
49 (if (file-exists-p "~/.exwm-work")
50 (progn
51 (require 'exwm-randr)
52 (setq exwm-randr-workspace-output-plist
53 '(0 "DisplayPort-0" 1 "DVI-0"))
54 (add-hook 'exwm-randr-screen-change-hook
55 (lambda ()
56 (start-process-shell-command
57 "xrandr" nil "xrandr --output DisplayPort-0 --below DVI-0")))
58 (exwm-randr-enable)))
59
60
61 ;; Enable EXWM
62 (exwm-enable)
63 ;; Configure Ido
64 (exwm-config-ido)
65 ;; Other configurations
66 (exwm-config-misc))
67
68 (defun exwm-config--fix/ido-buffer-window-other-frame ()
69 "Fix `ido-buffer-window-other-frame'."
70 (defalias 'exwm-config-ido-buffer-window-other-frame
71 (symbol-function #'ido-buffer-window-other-frame))
72 (defun ido-buffer-window-other-frame (buffer)
73 "This is a version redefined by EXWM.
74 You can find the original one at `exwm-config-ido-buffer-window-other-frame'."
75 (with-current-buffer (window-buffer (selected-window))
76 (if (and (derived-mode-p 'exwm-mode)
77 exwm--floating-frame)
78 ;; Switch from a floating frame.
79 (with-current-buffer buffer
80 (if (and (derived-mode-p 'exwm-mode)
81 exwm--floating-frame
82 (eq exwm--frame exwm-workspace--current))
83 ;; Switch to another floating frame.
84 (frame-root-window exwm--floating-frame)
85 ;; Do not switch if the buffer is not on the current workspace.
86 (or (get-buffer-window buffer exwm-workspace--current)
87 (selected-window))))
88 (with-current-buffer buffer
89 (when (derived-mode-p 'exwm-mode)
90 (if (eq exwm--frame exwm-workspace--current)
91 (when exwm--floating-frame
92 ;; Switch to a floating frame on the current workspace.
93 (frame-selected-window exwm--floating-frame))
94 ;; Do not switch to exwm-mode buffers on other workspace (which
95 ;; won't work unless `exwm-layout-show-all-buffers' is set)
96 (unless exwm-layout-show-all-buffers
97 (selected-window)))))))))
98
99 (defun exwm-config-ido ()
100 "Configure Ido to work with EXWM."
101 (ido-mode 1)
102 (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame))
103
104 (defun exwm-config-misc ()
105 "Other configurations."
106 ;; Make more room
107 (menu-bar-mode -1)
108 (tool-bar-mode -1)
109 (scroll-bar-mode -1)
110 (fringe-mode 1))
111
112
113 (provide 'exwm-config-spw)