;; Time-stamp: <2020-04-21 19:17:12 (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-index 0) (defun exwm-workspace-lighter () (format " @%d (*%d)" exwm-workspace-current-index exwm-workspace-last-index)) (defun exwm-store-workspace-last-index (next) (when (/= next exwm-workspace-current-index) (setq exwm-workspace-last-index exwm-workspace-current-index))) (advice-add 'exwm-workspace-switch-create :before #'exwm-store-workspace-last-index) ;; (advice-add 'exwm-workspace-switch :before #'exwm-store-workspace-last-index) (defun exwm-sanitise-workspace-last-index () (when (> (1+ exwm-workspace-last-index) (exwm-workspace--count)) (setq exwm-workspace-last-index exwm-workspace-current-index))) (push #'exwm-sanitise-workspace-last-index exwm-workspace-list-change-hook) (defun exwm-last-workspace () (interactive) (exwm-workspace-switch-create exwm-workspace-last-index)) (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) ;; ------------------------------------------------------------------- ;; 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 :config (add-hook 'exwm-edit-compose-hook (lambda () (text-mode))))