exwm-config.el 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. (if (file-exists-p "~/.exwm-work")
  47. (progn
  48. (require 'exwm-randr)
  49. (setq exwm-randr-workspace-output-plist
  50. '(0 "DisplayPort-0" 1 "DVI-0"))
  51. (add-hook 'exwm-randr-screen-change-hook
  52. (lambda ()
  53. (start-process-shell-command
  54. "xrandr" nil "xrandr --output DisplayPort-0 --below DVI-0")))
  55. (exwm-randr-enable)))
  56. ;; Enable EXWM
  57. (exwm-enable)
  58. ;; Configure Ido
  59. (exwm-config-ido)
  60. ;; Other configurations
  61. (exwm-config-misc))
  62. (defun exwm-config--fix/ido-buffer-window-other-frame ()
  63. "Fix `ido-buffer-window-other-frame'."
  64. (defalias 'exwm-config-ido-buffer-window-other-frame
  65. (symbol-function #'ido-buffer-window-other-frame))
  66. (defun ido-buffer-window-other-frame (buffer)
  67. "This is a version redefined by EXWM.
  68. You can find the original one at `exwm-config-ido-buffer-window-other-frame'."
  69. (with-current-buffer (window-buffer (selected-window))
  70. (if (and (derived-mode-p 'exwm-mode)
  71. exwm--floating-frame)
  72. ;; Switch from a floating frame.
  73. (with-current-buffer buffer
  74. (if (and (derived-mode-p 'exwm-mode)
  75. exwm--floating-frame
  76. (eq exwm--frame exwm-workspace--current))
  77. ;; Switch to another floating frame.
  78. (frame-root-window exwm--floating-frame)
  79. ;; Do not switch if the buffer is not on the current workspace.
  80. (or (get-buffer-window buffer exwm-workspace--current)
  81. (selected-window))))
  82. (with-current-buffer buffer
  83. (when (derived-mode-p 'exwm-mode)
  84. (if (eq exwm--frame exwm-workspace--current)
  85. (when exwm--floating-frame
  86. ;; Switch to a floating frame on the current workspace.
  87. (frame-selected-window exwm--floating-frame))
  88. ;; Do not switch to exwm-mode buffers on other workspace (which
  89. ;; won't work unless `exwm-layout-show-all-buffers' is set)
  90. (unless exwm-layout-show-all-buffers
  91. (selected-window)))))))))
  92. (defun exwm-config-ido ()
  93. "Configure Ido to work with EXWM."
  94. (ido-mode 1)
  95. (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame))
  96. (defun exwm-config-misc ()
  97. "Other configurations."
  98. ;; Make more room
  99. (menu-bar-mode -1)
  100. (tool-bar-mode -1)
  101. (scroll-bar-mode -1)
  102. (fringe-mode 1))
  103. (provide 'exwm-config-spw)