Skip to content

Instantly share code, notes, and snippets.

@maxking
Created September 20, 2015 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxking/9ac098c250390bf44bdf to your computer and use it in GitHub Desktop.
Save maxking/9ac098c250390bf44bdf to your computer and use it in GitHub Desktop.
This is a script to auto-enable/disable an external display. I bind it to the screen-switch button used in windows and it works like a charm.
#!/usr/bin/env bash
xrandr | grep VGA | grep -w connected >/dev/null
echo $?
if [[ "$?" -lt 1 ]]
then
notify-send "Extending desktop to VGA screen"
xrandr --output LVDS1 --auto --output VGA1 --auto --left-of LVDS1 --primary
else
xrandr --output LVDS1 --auto --primary
notify-send "No known screens found"
fi
@maxking
Copy link
Author

maxking commented Sep 20, 2015

Note: This script won't work out of box. You would have to configure external display's you are going to connect and modify the script according to your use. This is just a sample script that works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment