
Thank you all for the wonderful suggestions. There are definitely many
good options available that I was not aware of.
I've tried a few and autorandr seems like a good addition into my already
(more or less) working workflow. It solves the specific problem that I've
described. In the future, I might try and replace my custom script with a
different end-to-end solution.
On Tue, Jul 13, 2021 at 2:22 PM Tomas Janousek
Hi,
On Fri, Jul 09, 2021 at 05:14:54PM +0300, Eyal Erez wrote:
I often use multiple displays. Here are some configurations that I've used {.quotelead}>with my laptop:
[…] I was wondering how others deal with this challenge? Are there other, more well-built tools, than the script I have to do this more robustly and automatically?
There are many ways to do this. I'll describe my setup and then point to some alternatives. ------------------------------
I have a script https://work.lisk.in/2020/10/11/xrandr-ux.html that extends xrandr command-line usage so that I can just write a generic vertical layout like so:
xrandr-smart --output 'eDP-*' --auto \ --output '!(eDP-*)' --auto --above 'eDP-*'
Then I have another script https://github.com/liskin/dotfiles/blob/home/bin/layout-auto that lets me save layouts for specific configurations https://github.com/liskin/dotfiles/tree/home/bin/.xlayout of connected monitors. This one is invoked automatically whenever an output is connected/disconnected, using https://xmonad.github.io/xmonad-docs/xmonad-contrib-0.16.999/XMonad-Hooks-Re... . I can also invoke it manually via a keybinding to force a laptop-only layout, or to force an automatic multi-head layout in an unknown setup. If I need something extra (like external monitor only for games), I just invoke a "layout-extonly" script via rofi https://github.com/davatorium/rofi (I only need to type "ex" for it to know what I mean).
(Re)starting xmobars and trayers is handled by https://xmonad.github.io/xmonad-docs/xmonad-contrib-0.16.999/XMonad-Hooks-St..., as mentioned by Yecine earlier.
In my setup, the automatic switching doesn't happen when the screen is locked, and neither do the keybindings work, but that is just my paranoia (and yeah, I should just use https://packages.debian.org/experimental/cryptsetup-suspend instead :-)). It's totally possible to let X.H.Rescreen invoke the script even if locked, and xsecurelock https://github.com/google/xsecurelock allows configuration of keybindings when the screen is locked. ------------------------------
Now for the alternatives:
Others have mentioned autorandr. That is probably what most minimalist window manager users use. Autorandr can be invoked on output (dis)connect, lid open/close and suspend/resume in various ways:
- https://xmonad.github.io/xmonad-docs/xmonad-contrib-0.16.999/XMonad-Hooks-Re... - https://github.com/jceb/srandrd - https://github.com/phillipberndt/autorandr/blob/master/contrib/autorandr_lau... - https://github.com/phillipberndt/autorandr/blob/master/contrib/listen_lid.sh - https://github.com/phillipberndt/autorandr/blob/master/contrib/pm-utils/40au...
Also see https://wiki.archlinux.org/title/xrandr for other tools and tips. -- Tomáš "liskin" ("Pivník") Janoušek, https://work.lisk.in/
--
*Eyal Erez <**oneself@gmail.com*