My attempt to optimize my emacs load time <1 second
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.

138 lines
5.0 KiB

  1. ;;; custom-exwm --- Provide EXWM specific config
  2. ;;; Commentary:
  3. ;;; Code:
  4. (defun leo/which-session ()
  5. "Return the current Xsession name. i.e. i3, exwm, etc..."
  6. (shell-command-to-string "cat ~/.dmrc | tail -n1 | awk -F'=' '{print $2}' | tr -d \"\n\""))
  7. (when (string-equal "exwm" (eval (leo/which-session)))
  8. ;; https://github.com/ch11ng/exwm
  9. (use-package exwm
  10. :ensure t
  11. :demand t
  12. :bind
  13. ("<XF86AudioLowerVolume>" . (lambda() (interactive) (shell-command-to-string "amixer sset Master 2%-")))
  14. ("<XF86AudioRaiseVolume>" . (lambda() (interactive) (shell-command-to-string "amixer sset Master 2%+")))
  15. ("<XF86AudioMute>" . (lambda() (interactive) (shell-command-to-string "amixer sset Master 0")))
  16. ("<pause>" . (lambda() (interactive) (shell-command-to-string "playerctl play-pause")))
  17. ("<XF86AudioPrev>" . (lambda() (interactive) (shell-command-to-string "playerctl next")))
  18. ("<XF86AudioNext>" . (lambda() (interactive) (shell-command-to-string "playerctl prev")))
  19. :custom
  20. (exwm-workspace-show-all-buffers t "Show all buffers regardless of current workspace.")
  21. (exwm-workspace-warp-cursor t "Move cursor when window focus changes.")
  22. :config
  23. (require 'exwm-config)
  24. (exwm-config-default)
  25. (display-time-mode 1)
  26. (display-battery-mode 1)
  27. (require 'exwm-systemtray)
  28. (exwm-systemtray-enable)
  29. (require 'exwm-randr)
  30. (defun leo/exwm-change-screen-hook ()
  31. (let ((xrandr-output-regexp "\n\\([^ ]+\\) connected ")
  32. default-output)
  33. (with-temp-buffer
  34. (call-process "xrandr" nil t nil)
  35. (goto-char (point-min))
  36. (re-search-forward xrandr-output-regexp nil 'noerror)
  37. (setq default-output (match-string 1))
  38. (forward-line)
  39. (if (not (re-search-forward xrandr-output-regexp nil 'noerror))
  40. (call-process "xrandr" nil nil nil "--output" default-output "--auto")
  41. (call-process
  42. "xrandr" nil nil nil
  43. "--output" default-output "--primary" "--auto"
  44. "--output" (match-string 1) "--off")
  45. (setq exwm-randr-workspace-output-plist (list 0 default-output))))))
  46. (add-hook 'exwm-randr-screen-change-hook 'leo/exwm-change-screen-hook)
  47. (exwm-randr-enable)
  48. ;; (start-process "polybar" "*polybar*" "~/scripts/polybar/polybar_launch")
  49. (setq exwm-workspace-index-map (lambda (i) (number-to-string (1+ i))))
  50. (dolist (k '(XF86AudioLowerVolume
  51. XF86AudioRaiseVolume
  52. XF86AudioMude
  53. pause
  54. XF86AudioPrev
  55. XF86AudioNext))
  56. (push k exwm-input-prefix-keys))
  57. (setq exwm-input-simulation-keys
  58. '(
  59. ;; movement
  60. ([?\C-b] . [left])
  61. ([?\M-b] . [C-left])
  62. ([?\C-f] . [right])
  63. ([?\M-f] . [C-right])
  64. ([?\C-p] . [up])
  65. ([?\C-n] . [down])
  66. ([?\C-a] . [home])
  67. ([?\C-e] . [end])
  68. ([?\M-v] . [prior])
  69. ([?\C-v] . [next])
  70. ([?\C-d] . [delete])
  71. ([?\C-k] . [S-end delete])
  72. ;; cut/paste.
  73. ([?\C-w] . [?\C-x])
  74. ([?\M-w] . [?\C-c])
  75. ([?\C-y] . [?\C-v])
  76. ;; search
  77. ([?\C-s] . [?\C-f])))
  78. (setq exwm-input-global-keys
  79. `(
  80. ;; Bind "s-r" to exit char-mode and fullscreen mode.
  81. ([?\s-r] . exwm-reset)
  82. ;; Super + R to restart exwm
  83. ([8388690] . exwm-restart)
  84. ;; Bind "s-w" to switch workspace interactively.
  85. ([?\s-w] . exwm-workspace-switch)
  86. ;; Bind "s-!" to "s-^" to switch to a workspace by its index.
  87. ([8388641] . (lambda ()(interactive) (exwm-workspace-switch-create 1)))
  88. ([8388672] . (lambda ()(interactive) (exwm-workspace-switch-create 2)))
  89. ([8388643] . (lambda ()(interactive) (exwm-workspace-switch-create 3)))
  90. ([8388644] . (lambda ()(interactive) (exwm-workspace-switch-create 4)))
  91. ([8388645] . (lambda ()(interactive) (exwm-workspace-switch-create 5)))
  92. ([8388702] . (lambda ()(interactive) (exwm-workspace-switch-create 6)))
  93. ([8388649] . (lambda ()(interactive) (exwm-workspace-switch-create 0)))
  94. ;; Open ST in other window
  95. ([s-return] . (lambda ()(interactive) (split-window-right) (other-window) (start-process "" nil "st")))
  96. ;; Bind "s-<f2>" to "slock", a simple X display locker.
  97. ;; ([s-f2] . (lambda ()
  98. ;; (interactive)
  99. ;; (start-process "" nil "/usr/bin/slock")))))
  100. )
  101. )
  102. )
  103. (use-package exwm-edit
  104. :ensure t
  105. :config
  106. (defun ag-exwm/on-exwm-edit-compose ()
  107. (spacemacs/toggle-visual-line-navigation-on)
  108. (funcall 'markdown-mode))
  109. ;; (add-hook 'exwm-edit-compose-hook 'ag-exwm/on-exwm-edit-compose))
  110. )
  111. ;; https://github.com/emacsmirror/dmenu
  112. (use-package dmenu
  113. :ensure t
  114. :bind ("s-SPC" . dmenu)
  115. )
  116. )
  117. (provide 'custom-exwm)
  118. ;;; custom-exwm.el ends here