;;; init-exwm.el --- exwm config -*- lexical-binding: t -*- ;;; Commentary: ;;; Code: (when *is-linux* (use-package exwm :config (setq exwm-workspace-number 1) (exwm-input-set-key (kbd "s-&") (lambda (command) (interactive (list (read-shell-command "$ "))) (let ((display-buffer-alist '((".*" . (display-buffer-no-window . nil))))) (async-shell-command command)))) (defun my--exwm-switch-to-workspace (delta) (let ((target (mod (+ exwm-workspace-current-index delta) (length exwm-workspace--list)))) (exwm-workspace-switch target) (if (= 1 (length exwm-workspace--list)) (message "Single workspace active")))) (defun my-exwm-next-workspace () "Switch to next exwm workspace." (interactive) (my--exwm-switch-to-workspace 1)) (defun my-exwm-previous-workspace () "Switch to previous exwm workspace." (interactive) (my--exwm-switch-to-workspace -1)) (global-set-key (kbd "s-]") 'my-exwm-next-workspace) (global-set-key (kbd "s-[") 'my-exwm-previous-workspace) (add-to-list 'global-mode-string '(:eval (propertize (format " WS:%d " exwm-workspace-current-index) 'face 'mode-line-emphasis)) t) (setq exwm-input-prefix-keys '(?\C-x ?\C-u ?\C-c ?\C-h ?\M-x ?\M-o ?\M-[ ?\M-] ?\s-[ ?\s-] XF86AudioLowerVolume XF86AudioRaiseVolume XF86AudioMute )) (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key) (setq exwm-input-global-keys `(([?\s-r] . exwm-reset) ([?\s-b] . windmove-left) ([?\s-f] . windmove-right) ([?\s-p] . windmove-up) ([?\s-n] . windmove-down) ([?\s-S] . desktop-environment-screenshot) ([?\s-s] . desktop-environment-screenshot-part) ([?\s-w] . exwm-workspace-switch) ([?\s-o] . other-window) ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0))) ,@(mapcar (lambda (i) `(,(kbd(format "s-%d" i)) . (lambda () (interactive) (exwm-workspace-switch-create ,i)))) (number-sequence 0 9)))) (defun my/exwm-update-class () (exwm-workspace-rename-buffer exwm-class-name)) (add-hook 'exwm-update-class-hook #'my/exwm-update-class) (require 'exwm-xim) (exwm-xim-mode) (exwm-wm-mode)) (use-package desktop-environment :init (desktop-environment-mode) :config (advice-add 'desktop-environment-screenshot :after (lambda (&rest _) (message "Saved fullscreen screenshot."))) (advice-add 'desktop-environment-screenshot-part :after (lambda (&rest _) (message "Saved partial screenshot."))) :custom (desktop-environment-screenshot-command "import -window root ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png") (desktop-environment-screenshot-partial-command "import ~/Pictures/screenshot-$(date +%Y%m%d-%H%M%S).png")) (defun vscodium () "Run VSCodium via shell command asynchronously." (interactive) (start-process-shell-command "vscodium" nil "flatpak run com.vscodium.codium")) (defun localsend () "Run localsend via shell command asynchronously." (interactive) (start-process-shell-command "localsend" nil "flatpak run org.localsend.localsend_app")) (defun steam () "Run Steam via shell command asynchronously." (interactive) (start-process-shell-command "steam" nil "flatpak run com.valvesoftware.Steam")) (add-hook 'exwm-init-hook (lambda () (unless (zerop (shell-command "pgrep -x fcitx5")) (start-process-shell-command "fcitx5" nil "fcitx5 -d")) (unless (zerop (shell-command "pgrep -x mihomo")) (start-process-shell-command "mihomo" nil "mihomo -d ~/.config/mihomo/")) (start-process-shell-command "xrandr-refresh" nil "xrandr --output DP-4 --mode 2560x1440 --rate 165.00") (start-process-shell-command "xinput" nil "xinput set-prop 12 'libinput Accel Speed' -0.45"))) ) (provide 'init-exwm) ;;; init-exwm.el ends here