Reorganise EXWM config a little
This commit is contained in:
60
config.org
60
config.org
@@ -345,41 +345,47 @@ needs to be set up to install them if they aren't already.
|
|||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package exwm
|
(use-package exwm
|
||||||
:config
|
:config
|
||||||
(require 'exwm-randr)
|
|
||||||
(exwm-randr-enable)
|
|
||||||
(require 'exwm-config)
|
(require 'exwm-config)
|
||||||
(exwm-config-default))
|
(exwm-config-default))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
When I have my laptop connected to a monitor I want the built-in
|
*** Multi-monitor
|
||||||
display to turn off, but turn back on when it's disconnected. Turns
|
Multi-monitor support is provided in =exwm-randr=:
|
||||||
out this is a total pain.
|
|
||||||
|
|
||||||
To start with we need a function to tell whether a monitor's
|
#+begin_src emacs-lisp
|
||||||
attached. =exwm-randr= provides [[help:exwm-randr--get-monitors][exwm-randr--get-monitors]], but its
|
(require 'exwm-randr)
|
||||||
result is not -- as I'd expect -- a list of monitors, but instead a
|
(exwm-randr-enable)
|
||||||
rather complicated mess that is (as far as I can tell)
|
#+end_src
|
||||||
undocumented. Rather than trying to figure out what was going on
|
|
||||||
there, I opted for the search-in-shell-command-output route
|
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
When I have my laptop connected to a monitor I want the built-in
|
||||||
(defun hdmi-connected-p ()
|
display to turn off, but turn back on when it's disconnected. Turns
|
||||||
(string-match-p "HDMI-2 connected"
|
out this is a total pain.
|
||||||
(shell-command-to-string "xrandr")))
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
With that defined, an [[help:exwm-randr-screen-change-hook][exwm-randr-screen-change-hook]] can then be
|
To start with we need a function to tell whether a monitor's
|
||||||
added to turn the built-in display on and off appropriately.
|
attached. =exwm-randr= provides [[help:exwm-randr--get-monitors][exwm-randr--get-monitors]], but its
|
||||||
|
result is not -- as I'd expect -- a list of monitors, but instead a
|
||||||
|
rather complicated mess that is (as far as I can tell)
|
||||||
|
undocumented. Rather than trying to figure out what was going on
|
||||||
|
there, I opted for the search-in-shell-command-output route
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(add-hook 'exwm-randr-screen-change-hook
|
(defun hdmi-connected-p ()
|
||||||
(lambda ()
|
(string-match-p "HDMI-2 connected"
|
||||||
(let ((xrandr-command
|
(shell-command-to-string "xrandr")))
|
||||||
(if (hdmi-connected-p)
|
#+end_src
|
||||||
"xrandr --output eDP-1 --off --output HDMI-2 --auto"
|
|
||||||
"xrandr --output eDP-1 --auto")))
|
With that defined, an [[help:exwm-randr-screen-change-hook][exwm-randr-screen-change-hook]] can then be
|
||||||
(start-process-shell-command "xrandr" nil xrandr-command))))
|
added to turn the built-in display on and off appropriately.
|
||||||
#+end_src
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(add-hook 'exwm-randr-screen-change-hook
|
||||||
|
(lambda ()
|
||||||
|
(let ((xrandr-command
|
||||||
|
(if (hdmi-connected-p)
|
||||||
|
"xrandr --output eDP-1 --off --output HDMI-2 --auto"
|
||||||
|
"xrandr --output eDP-1 --auto")))
|
||||||
|
(start-process-shell-command "xrandr" nil xrandr-command))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** Mode Line
|
** Mode Line
|
||||||
*** Clock
|
*** Clock
|
||||||
|
|||||||
Reference in New Issue
Block a user