Arch Dual Monitor configuration
I have two monitors and only ever use one at a time, I have a script and keyboard shortcut to switch between them but at the moment 99% of my time is at one monitor.
When I login I have script switch the other monitor off but after putting the machine to sleep they both wake up. I can manually run the script to turn the unneeded one off but because I cannot see it I often forget.
So here is my solution.
I created a file
/usr/lib/systemd/system-sleep/monitor.sh
and in it has
#!/bin/sh case $1/$2 in pre/*) ;; post/*) sleep 5 export DISPLAY=:0 sudo -u simon xrandr --output HDMI-0 --off > /tmp/randr.dbg 2>&1 ;; esac
The script must be executable so
sudo chmod +x /usr/lib/systemd/system-sleep/monitor.shThe sleep part is needed to wait until both displays are awake, otherwise the command fails.
The sudo to my user is the extra piece that took some finding, a special thanks to this thread for pointing out a solution.
If you need a different option you can use any xrandr command and it will work.