Add multi-monitor support to EXWM config
This commit is contained in:
parent
e52af46621
commit
5ab55e289d
50
config.org
50
config.org
@ -312,15 +312,49 @@ needs to be set up to install them if they aren't already.
|
||||
(use-package yaml-mode)
|
||||
#+end_src
|
||||
|
||||
* EXWM
|
||||
One must fulfil the meme of doing everything with Emacs...
|
||||
* Desktop
|
||||
** EXWM
|
||||
One must fulfil the meme of doing everything with Emacs... still
|
||||
got a lot of tweaking to do here before I'm happy.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package exwm
|
||||
:config
|
||||
(require 'exwm-config)
|
||||
(exwm-config-default))
|
||||
#+end_src
|
||||
#+begin_src emacs-lisp
|
||||
(use-package exwm
|
||||
:config
|
||||
(require 'exwm-randr)
|
||||
(exwm-randr-enable)
|
||||
(require 'exwm-config)
|
||||
(exwm-config-default))
|
||||
#+end_src
|
||||
|
||||
When I have my laptop connected to a monitor I want the built-in
|
||||
display to turn off, but turn back on when it's disconnected. Turns
|
||||
out this is a total pain.
|
||||
|
||||
To start with we need a function to tell whether a monitor's
|
||||
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
|
||||
(defun hdmi-connected-p ()
|
||||
(string-match-p "HDMI-2 connected"
|
||||
(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
|
||||
added to turn the built-in display on and off appropriately.
|
||||
|
||||
#+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
|
||||
|
||||
* Passwords
|
||||
This was a little more work than I expected... =password-store=
|
||||
|
Loading…
x
Reference in New Issue
Block a user