exwm-config.el 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. (require 'exwm)
  2. (require 'ido)
  3. (define-obsolete-function-alias 'exwm-config-default
  4. #'exwm-config-example "27.1")
  5. (defun exwm-config-spw ()
  6. "Default configuration of EXWM."
  7. ;; Set the initial workspace number.
  8. (unless (get 'exwm-workspace-number 'saved-value)
  9. (setq exwm-workspace-number 4))
  10. ;; Make class name the buffer name
  11. (add-hook 'exwm-update-class-hook
  12. (lambda ()
  13. (exwm-workspace-rename-buffer exwm-class-name)))
  14. ;; Global keybindings.
  15. (unless (get 'exwm-input-global-keys 'saved-value)
  16. (setq exwm-input-global-keys
  17. `(
  18. ;; 's-r': Reset (to line-mode).
  19. ([?\s-r] . exwm-reset)
  20. ;; 's-w': Switch workspace.
  21. ([?\s-w] . exwm-workspace-switch)
  22. ;; 's-&': Launch application.
  23. ([?\s-&] . (lambda (command)
  24. (interactive (list (read-shell-command "$ ")))
  25. (start-process-shell-command command nil command)))
  26. ;; 's-N': Switch to certain workspace.
  27. ,@(mapcar (lambda (i)
  28. `(,(kbd (format "s-%d" i)) .
  29. (lambda ()
  30. (interactive)
  31. (exwm-workspace-switch-create ,i))))
  32. (number-sequence 0 9)))))
  33. ;; Line-editing shortcuts
  34. (unless (get 'exwm-input-simulation-keys 'saved-value)
  35. (setq exwm-input-simulation-keys
  36. '(([?\C-b] . [left])
  37. ([?\C-f] . [right])
  38. ([?\C-p] . [up])
  39. ([?\C-n] . [down])
  40. ([?\C-a] . [home])
  41. ([?\C-e] . [end])
  42. ([?\M-v] . [prior])
  43. ([?\C-v] . [next])
  44. ([?\C-d] . [delete])
  45. ([?\C-k] . [S-end delete]))))
  46. (require 'exwm-randr)
  47. (setq exwm-randr-workspace-output-plist
  48. '(0 "DisplayPort-0" 1 "DVI-0"))
  49. (add-hook 'exwm-randr-screen-change-hook
  50. (lambda ()
  51. (start-process-shell-command
  52. "xrandr" nil "xrandr --output DisplayPort-0 --below DVI-0")))
  53. (exwm-randr-enable)
  54. ;; Enable EXWM
  55. (exwm-enable)
  56. ;; Configure Ido
  57. (exwm-config-ido)
  58. ;; Other configurations
  59. (exwm-config-misc))
  60. (defun exwm-config--fix/ido-buffer-window-other-frame ()
  61. "Fix `ido-buffer-window-other-frame'."
  62. (defalias 'exwm-config-ido-buffer-window-other-frame
  63. (symbol-function #'ido-buffer-window-other-frame))
  64. (defun ido-buffer-window-other-frame (buffer)
  65. "This is a version redefined by EXWM.
  66. You can find the original one at `exwm-config-ido-buffer-window-other-frame'."
  67. (with-current-buffer (window-buffer (selected-window))
  68. (if (and (derived-mode-p 'exwm-mode)
  69. exwm--floating-frame)
  70. ;; Switch from a floating frame.
  71. (with-current-buffer buffer
  72. (if (and (derived-mode-p 'exwm-mode)
  73. exwm--floating-frame
  74. (eq exwm--frame exwm-workspace--current))
  75. ;; Switch to another floating frame.
  76. (frame-root-window exwm--floating-frame)
  77. ;; Do not switch if the buffer is not on the current workspace.
  78. (or (get-buffer-window buffer exwm-workspace--current)
  79. (selected-window))))
  80. (with-current-buffer buffer
  81. (when (derived-mode-p 'exwm-mode)
  82. (if (eq exwm--frame exwm-workspace--current)
  83. (when exwm--floating-frame
  84. ;; Switch to a floating frame on the current workspace.
  85. (frame-selected-window exwm--floating-frame))
  86. ;; Do not switch to exwm-mode buffers on other workspace (which
  87. ;; won't work unless `exwm-layout-show-all-buffers' is set)
  88. (unless exwm-layout-show-all-buffers
  89. (selected-window)))))))))
  90. (defun exwm-config-ido ()
  91. "Configure Ido to work with EXWM."
  92. (ido-mode 1)
  93. (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame))
  94. (defun exwm-config-misc ()
  95. "Other configurations."
  96. ;; Make more room
  97. (menu-bar-mode -1)
  98. (tool-bar-mode -1)
  99. (scroll-bar-mode -1)
  100. (fringe-mode 1))
  101. (provide 'exwm-config-spw)