;;; exwm.el -*- lexical-binding: t; -*- (defun exwm-config--fix/ido-buffer-window-other-frame () "Fix `ido-buffer-window-other-frame'." (defalias 'exwm-config-ido-buffer-window-other-frame (symbol-function #'ido-buffer-window-other-frame)) (defun ido-buffer-window-other-frame (buffer) "This is a version redefined by EXWM. You can find the original one at `exwm-config-ido-buffer-window-other-frame'." (with-current-buffer (window-buffer (selected-window)) (if (and (derived-mode-p 'exwm-mode) exwm--floating-frame) ;; Switch from a floating frame. (with-current-buffer buffer (if (and (derived-mode-p 'exwm-mode) exwm--floating-frame (eq exwm--frame exwm-workspace--current)) ;; Switch to another floating frame. (frame-root-window exwm--floating-frame) ;; Do not switch if the buffer is not on the current workspace. (or (get-buffer-window buffer exwm-workspace--current) (selected-window)))) (with-current-buffer buffer (when (derived-mode-p 'exwm-mode) (if (eq exwm--frame exwm-workspace--current) (when exwm--floating-frame ;; Switch to a floating frame on the current workspace. (frame-selected-window exwm--floating-frame)) ;; Do not switch to exwm-mode buffers on other workspace (which ;; won't work unless `exwm-layout-show-all-buffers' is set) (unless exwm-layout-show-all-buffers (selected-window))))))))) (defun exwm-config-ido () "Configure Ido to work with EXWM." (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame)) (defun follie/run-in-background (command) (let ((command-parts (split-string command "[ ]+"))) (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts))))) (defun follie/set-wallpaper () (interactive) (start-process-shell-command "feh" nil "feh --no-fehbg --bg-fill --randomize ~/Pictures/Wallpapers/*")) (defun follie/exwm-init-hook () ;; Make workspace 1 the default at startup ;;(exwm-workspace-switch-create 1) ;; Open eshell at startup ;;(eshell) ;; Additional status info on modeline (setq display-time-day-and-date t) (display-time-mode 1) (if (not (equal "Battery status not available" (battery))) (display-battery-mode 1)) ;; Startup apps (follie/run-in-background "pipewire") (follie/run-in-background "dunst") (follie/run-in-background "mpDris2") (start-process-shell-command "xsetroot" nil "xsetroot -cursor_name left_ptr")) (defun follie/configure-window-by-class () (interactive) (pcase exwm-class-name ("Komikku" (exwm-floating-toggle-floating) (exwm-layout-toggle-mode-line)))) (defun follie/update-displays () (lambda () (start-process-shell-command "xrandr" nil "xrandr --output eDP-1 --mode 1920x1080 --pos 0x0 --rotate normal --output HDMI-1 --mode 1920x1080 --pos 1920x0 --rotate normal")) (follie/set-wallpaper) (message "Displays updated")) (use-package! exwm :config ;; Number of workspaces (setq exwm-workspace-number 2) ;; Extra stuff at startup (add-hook 'exwm-init-hook #'follie/exwm-init-hook) ;; Update buffer name (add-hook 'exwm-update-class-hook (lambda () (exwm-workspace-rename-buffer exwm-class-name))) ;; Window rules (add-hook 'exwm-manage-finish-hook #'follie/configure-window-by-class) ;; Automatically move EXWM buffer to current workspace ;;(setq exwm-layout-show-all-buffers t) ;; Display all buffers in every workspace buffer list (setq exwm-workspace-show-all-buffers t) ;; Multi monitor (require 'exwm-randr) (setq exwm-randr-workspace-monitor-plist '(1 "HDMI-1")) (add-hook 'exwm-randr-screen-change-hook #'follie/update-displays) (exwm-randr-enable) ;; Set wallpapers after changing resolution ;;(follie/set-wallpaper) ;; System tray on minibuffer (require 'exwm-systemtray) (setq exwm-systemtray-height 12) (exwm-systemtray-enable) ;; Automatically send cursor to the selected display (setq exwm-workspace-warp-cursor t) ;; Focus follows cursor (setq mouse-autoselect-window t focus-follows-mouse t) ;; Keys that always pass through to Emacs in line-mode (setq exwm-input-prefix-keys '(?\C-x ?\C-u ?\C-h ?\M-x ?\M-` ?\M-& ?\M-: ?\C-\M-j)) ;; Buffer list ;; Ctrl+q to enable next key to be sent directly (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key) ;; Global key bindings (setq exwm-input-global-keys `( ;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard) ([?\s-r] . exwm-reset) ;; Move between windows ([s-left] . windmove-left) ([s-right] . windmove-right) ([s-up] . windmove-up) ([s-down] . windmove-down) ;; Launch applications via shell command ([?\s-&] . (lambda (command) (interactive (list (read-shell-command "$ "))) (start-process-shell-command command nil command))) ;; Switch workspace ([?\s-w] . exwm-workspace-switch) ([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0))) ;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9) ,@(mapcar (lambda (i) `(,(kbd (format "s-%d" i)) . (lambda () (interactive) (exwm-workspace-switch-create ,i)))) (number-sequence 0 9)))) (exwm-input-set-key (kbd "s-SPC") 'counsel-linux-app) ;; Enable EXWM (exwm-enable) ;; Work around ido frame (exwm-config-ido)) ;; Control dunst (defun follie/disable-desktop-notifications () (interactive) (start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_PAUSE\"")) (defun follie/enable-desktop-notifications () (interactive) (start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_RESUME\"")) (defun follie/toggle-desktop-notifications () (interactive) (start-process-shell-command "notify-send" nil "notify-send \"DUNST_COMMAND_TOGGLE\""))