I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB

  1. #+TITLE: EXWM
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args:emacs-lisp :tangle exwm.el :comments org
  5. #+PROPERTY: header-args :results silent :eval no-export :comments org
  6. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  7. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  8. Emacs can run as a complete tiling window manager for X11.
  9. * Setup
  10. Load the ~x11~ module before loading this module.
  11. * Config
  12. When ~exwm~[fn:1] first launches the ~init-hook~ is executed, allowing us to define some custom logic inside of a hook. Display the time and date, and the battery information, if any is available. I add this here because when I'm running Emacs without ~exwm~[fn:1], information such as the batter and time is typically already available.
  13. #+begin_src emacs-lisp
  14. (defun dotfiles/init-hook ()
  15. (exwm-workspace-switch-create 1)
  16. (setq display-time-and-date t)
  17. (display-battery-mode 1)
  18. (display-time-mode 1))
  19. #+end_src
  20. ** Display detection
  21. Enable hot plugging by forcing a profile change with ~autorandr~.
  22. #+begin_src emacs-lisp
  23. (defun dotfiles/update-display ()
  24. "Update the displays by forcing a change through autorandr."
  25. (dotfiles/run-in-background "autorandr --change --force"))
  26. #+end_src
  27. ** Window manager
  28. Connect all of the custom hooks and configure the input keys, a custom layer for key captures when Emacs us running as a window manager. Enable ~randr~ support, to function with ~autorandr~, and apply some default bindings.
  29. #+begin_src emacs-lisp
  30. (use-package exwm
  31. :when (window-system)
  32. :custom (exwm-workspace-show-all-buffers t)
  33. (exwm-input-prefix-keys
  34. '(?\M-x
  35. ?\C-g
  36. ?\C-\ ))
  37. (exwm-input-global-keys
  38. `(([?\s-r] . exwm-reset)
  39. ,@(mapcar (lambda (i)
  40. `(,(kbd (format "s-%d" i)) .
  41. (lambda ()
  42. (interactive)
  43. (exwm-workspace-switch-create ,i))))
  44. (number-sequence 1 9))))
  45. :config (require 'exwm-randr)
  46. (exwm-randr-enable)
  47. (add-hook 'exwm-init-hook #'dotfiles/init-hook)
  48. (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display)
  49. (add-hook 'exwm-update-class-hook (lambda () (exwm-workspace-rename-buffer exwm-class-name)))
  50. (dotfiles/update-display)
  51. (dotfiles/run-in-background "nitrogen --restore") ;; Update the wallpaper.
  52. (dotfiles/run-in-background "xmodmap") ;; Rebind CTRL and CAPS.
  53. (exwm-enable))
  54. #+end_src
  55. * Footnotes
  56. [fn:1] https://github.com/ch11ng/exwm