3

So I have a laptop I take to work and connect to a big monitor. Right now, when I get to work I do the following

  1. Connect my laptop to the monitor
  2. run xrandr --output DP1 --mode 2560x1600 --right-of eDP1 --output eDP1 --mode 1920x1080
  3. Restart my window manager. (I use i3, so it's actually a really cheap step)

When I leave work, I do the following:

  1. run xrandr --output eDP1 --mode 1920x1080 --output DP1 --off
  2. Restart my window manager.
  3. Disconnect the monitor.

This is annoying. Is there any way to "tell" my laptop that the above settings should be automatically applied whenever it connects to this monitor?

1

There is already an answer to this question. It boils down to the following points:

  • There is no event fired, polling is the only way
  • Polling is always bad, but some methods (as described in the linked answer) are more performant / lightweight than others

An alternative would be to create a script as the following (untested, but the idea is clear) and run that script, maybe using a keystroke:

# cat <<EOF >/usr/local/bin/fastxrr
#!/bin/sh
if xrandr | grep "eDP1 (connected)"
then
    xrandr SETUP FOR CONNECTED SCREEN
else
    xrandr SETUP FOR DISCONNECTED SCREEN
fi
EOF
# chmod +x /usr/local/bin/fastxrr

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.