I have a laptop running Ubuntu to which I connect an external monitor when I am in the office. This usually requires running xrandr --auto so that the laptop can resize the display to match the external monitor. It would be nice if it could be done automatically, or it worked when the monitor was connected, but it would be enough to run xrandr --auto when the laptop wakes up from standby / hibernation mode.
I created a script /etc/pm/sleep.d/00xrandr.sh containing the line
xrandr --auto
but this fails because the script does not have access to the X-display.
Any ideas?
source share