diff --git a/init.el b/init.el index 4cc1684..5a57d03 100644 --- a/init.el +++ b/init.el @@ -1024,92 +1024,6 @@ inserted between the braces between the braces." (devdocs-setup)) -;;; exwm -;;; ---- -;;; -;;; Only load [exwm](https://elpa.gnu.org/packages/exwm.html) if -;;; `MY_USE_EXWM` environment variable is set. - -(when (getenv "MY_USE_EXWM") - (use-package exwm - :init - (defun my-workspace (num) - `(,(kbd (format "s-%d" num)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,num)))) - - (defun my-workspace-fn (num) - `(,(kbd (format "s-" num)) . - (lambda () - (interactive) - (exwm-workspace-switch-create ,(+ 10 num))))) - - (defun my-workspace-name () - (let ((num (exwm-workspace--position - (exwm-workspace--workspace-from-frame-or-index - (selected-frame))))) - (if (>= num 10) - (format " " (- num 10)) - (format " <%d>" num)))) - - (setq my-previous-workspace 0 - my-current-workspace 0) - - (defun my-workspace-switch-hook-fn () - (let ((num (exwm-workspace--position - (exwm-workspace--workspace-from-frame-or-index - (selected-frame))))) - (if (/= num my-current-workspace) - (setq my-previous-workspace my-current-workspace - my-current-workspace num)))) - - (defun my-workspace-switch-previous () - (interactive) - (exwm-workspace-switch my-previous-workspace)) - - (defun my-run (command) - (interactive (list (read-shell-command "$ "))) - (start-process-shell-command command nil command)) - - (setq exwm-input-global-keys - `((,(kbd "s-p") . my-run) - (,(kbd "S-s-") . vterm) - (,(kbd "") . exwm-layout-toggle-fullscreen) - (,(kbd "s-J") . windmove-down) - (,(kbd "s-K") . windmove-up) - (,(kbd "s-H") . windmove-left) - (,(kbd "s-L") . windmove-right) - (,(kbd "s-") . my-workspace-switch-previous) - ,@ (mapcar #'my-workspace (number-sequence 0 9)) - ,@ (mapcar #'my-workspace-fn (number-sequence 1 12)))) - - (setq exwm-randr-workspace-monitor-plist - `(,@ (mapcan (lambda (i) (list i "DP-1")) - (number-sequence 0 9)) - ,@ (mapcan (lambda (i) (list i "HDMI-1")) - (number-sequence 11 22)))) - - (defun my-screen-change-hook-fn () - (start-process-shell-command - "xrandr" nil "xrandr --output HDMI-1 --right-of DP-1 --auto")) - - (defun my-update-class-hook-fn () - (exwm-workspace-rename-buffer exwm-class-name)) - - :config - (setq display-time-24hr-format t) - (display-time) - (set-default 'mode-line-format - (list '(:eval (my-workspace-name)) mode-line-format)) - (add-hook 'exwm-update-class-hook #'my-update-class-hook-fn) - (add-hook 'exwm-workspace-switch-hook #'my-workspace-switch-hook-fn) - (require 'exwm-randr) - (add-hook 'exwm-randr-screen-change-hook #'my-screen-change-hook-fn) - (exwm-enable) - (exwm-randr-enable))) - - ;;; Appearance and custom file ;;; --------------------------