Skip to content

Instantly share code, notes, and snippets.

@AndreaOrru
Created June 8, 2018 19:08
Show Gist options
  • Save AndreaOrru/1ddcd82c95beb8250bf17871d276f828 to your computer and use it in GitHub Desktop.
Save AndreaOrru/1ddcd82c95beb8250bf17871d276f828 to your computer and use it in GitHub Desktop.
EXWM configuration
(require 'exwm)
(require 'exwm-config)
;; Set the initial workspace number
(setq exwm-workspace-number 4)
(setq exwm-workspace-show-all-buffers t)
(setq exwm-layout-show-all-buffers t)
(setq exwm-input-line-mode-passthrough t)
(add-hook 'exwm-manage-finish-hook (lambda () (call-interactively #'exwm-input-release-keyboard)))
;; Ensure that when char mode is left, state is restored to normal
(advice-add 'exwm-input-grab-keyboard :after (lambda (&optional id)
(evil-normal-state)))
;; Ensure that when char mode is entered, input state is activated
(advice-add 'exwm-input-release-keyboard :after (lambda (&optional id)
(evil-insert-state)))
;; In normal state/line mode, use the familiar i key to switch to input state
(evil-define-key 'normal exwm-mode-map (kbd "i") 'exwm-input-release-keyboard)
(push ?\i exwm-input-prefix-keys)
;; Make class name the buffer name
(add-hook 'exwm-update-class-hook
(lambda ()
(exwm-workspace-rename-buffer exwm-class-name)))
;; 's-r': Reset
(exwm-input-set-key (kbd "s-<escape>") #'exwm-reset)
;; 's-w': Switch workspace
(exwm-input-set-key (kbd "s-w") #'exwm-workspace-switch)
;; 's-N': Switch to certain workspace
(defconst exwm-workspace-names '("q" "w" "e" "a" "s" "d" "z" "x" "c"))
(setq exwm-workspace-index-map (lambda (i) (nth i exwm-workspace-names)))
(dotimes (i 9)
(exwm-input-set-key (kbd (format "s-%s" (nth i exwm-workspace-names)))
`(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
;; 's-p': Launch application
(exwm-input-set-key (kbd "s-p") 'helm-run-external-command)
;; 's-RET': Launch terminal
(exwm-input-set-key (kbd "<s-return>")
(lambda ()
(interactive
(start-process-shell-command "termite" nil "termite"))))
;; Line-editing shortcuts
(setq exwm-input-simulation-keys
'(([?\C-b] . [left])
([?\C-f] . [right])
([?\C-p] . [up])
([?\C-n] . [down])
([?\C-a] . [home])
([?\C-e] . [end])
([?\M-v] . [prior])
([?\C-v] . [next])
([?\C-d] . [delete])
([?\C-k] . [S-end delete])))
;; Enable EXWM
(exwm-enable)
;; Configure Ido
(exwm-config-ido)
;; Other configurations
(exwm-config-misc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment