;; Time-stamp: <2020-05-05 20:25:35 (tslil@bison)> (defun banish-rat () (interactive) (shell-command "xdotool mousemove 1280 800") (message "Rat banished.")) (use-package exwm :if (window-system) :ensure t :demand :config (setq exwm-workspace-number 1 exwm-workspace-switch-create-limit 5 exwm-workspace-show-all-buffers nil) (add-hook 'exwm-update-class-hook (lambda () (exwm-workspace-rename-buffer exwm-class-name))) ;; ------------------------------------------------------------------- ;; Global key binds (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-s] . [C-f]) ;;([?\C-d] . [delete]) ;;([?\C-k] . [S-end delete]) )) ;; IME (defvar exwm-workman-intl t) (defun exwm-toggle-intl-ime () (interactive) (let ((result (call-process-shell-command (concat "setxkbmap -layout us -variant workman" (if exwm-workman-intl "-intl" "") " -option terminate:ctrl_alt_bksp -option ctrl:nocaps")))) (if (not (= 0 result)) (message "Unable to switch keyboard layouts.") (message (concat (if exwm-workman-intl "INTERNATIONAL" "STANDARD") " layout selected.")) (setq exwm-workman-intl (not exwm-workman-intl))))) (exwm-input-set-key (kbd "s-i") 'exwm-toggle-intl-ime) ;; reset (exwm-input-set-key (kbd "s-r") 'exwm-reset) ;; workspaces (exwm-input-set-key (kbd "s-e") 'exwm-workspace-switch) (dotimes (i 10) (exwm-input-set-key (kbd (format "s-%d" i)) `(lambda () (interactive) (exwm-workspace-switch-create ,i)))) ;; buffer and window management (exwm-input-set-key (kbd "s-SPC") 'switch-to-buffer) (defvar exwm-workspace-last-idx 0) (defvar exwm-workspace-current-idx 0) (defvar exwm-workspace-lighter "") (defun exwm-update-workspace-lighter () (setq exwm-workspace-lighter (format (concat "@%d" (when (/= exwm-workspace-current-idx exwm-workspace-last-idx) " (*%d)")) exwm-workspace-current-idx exwm-workspace-last-idx))) (defun exwm-workspace-track-changes (frame-or-index &optional ignored) (when (/= exwm-workspace-current-index exwm-workspace-current-idx) (setq exwm-workspace-last-idx exwm-workspace-current-idx exwm-workspace-current-idx exwm-workspace-current-index) (exwm-update-workspace-lighter))) (exwm-update-workspace-lighter) (advice-add 'exwm-workspace-switch :after #'exwm-workspace-track-changes) (advice-add 'exwm-workspace-switch-create :after #'exwm-workspace-track-changes) (defun exwm-sanitise-workspace-last-index () (when (and (< 0 (exwm-workspace--count)) (> (1+ exwm-workspace-last-idx) (exwm-workspace--count))) (setq exwm-workspace-last-idx exwm-workspace-current-idx) (exwm-update-workspace-lighter))) (push #'exwm-sanitise-workspace-last-index exwm-workspace-list-change-hook) (defun exwm-last-workspace () (interactive) (exwm-workspace-switch exwm-workspace-last-idx)) (defun exwm-last-buffer () (interactive) (switch-to-buffer (other-buffer (current-buffer) 1))) (exwm-input-set-key (kbd "s-o") 'exwm-last-buffer) (exwm-input-set-key (kbd "s-") 'exwm-last-workspace) (exwm-input-set-key (kbd "s-b") 'banish-rat) ;; run command (exwm-input-set-key (kbd "s-c") (lambda () (interactive) (start-process "" nil "st"))) (exwm-input-set-key (kbd "s-q") (lambda () (interactive) (start-process "" nil "iceweasel"))) (exwm-input-set-key (kbd "s-") (lambda () (interactive) (start-process "" nil "lock"))) (exwm-input-set-key (kbd "s-p") (lambda (command) (interactive (list (read-shell-command "$ "))) (start-process-shell-command command nil command))) ;; ------------------------------------------------------------------- ;; Tray (require 'exwm-systemtray) (exwm-systemtray-enable) (setq exwm-systemtray-height 24) ;; ------------------------------------------------------------------- ;; RandR (require 'exwm-randr) (exwm-randr-enable) (setq exwm-randr-workspace-monitor-plist '(1 "LVDS1" 0 "VGA1")) (exwm-enable)) ;; ----------------------------------------------------------------------------- ;; EXWM-edit (use-package exwm-edit :ensure t :if (and exwm-state (window-system)) :config (add-hook 'exwm-edit-compose-hook (lambda () (text-mode)))) ;; ----------------------------------------------------------------------------- ;; Statusbar.el (use-package posframe :defer 1 ;; HACK: why can't i just run this immediately after EXWM? :if (and (window-system) (fboundp 'exwm-systemtray-enable)) :ensure t) (use-package statusbar :if (and (window-system) (fboundp 'exwm-systemtray-enable)) :after posframe :load-path "~/.emacs.d/scripts/statusbar.el/" :config (advice-add 'exwm-update-workspace-lighter :after #'statusbar-refresh) (setq statusbar-modeline-variables '(exwm-workspace-lighter display-time-string)) (statusbar-mode +1))