Created
December 22, 2014 16:22
-
-
Save CarlosMecha/20743d60a72ab70b82fd to your computer and use it in GitHub Desktop.
Display switch script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# A tinny script based on: | |
# http://hoyhabloyo.wordpress.com/2012/01/18/xfce-display-switching-dual-single-monitor/ | |
# to configure automatically an external display. | |
# | |
{ | |
INT_DISPLAY='LVDS1'; | |
EXT_DISPLAY='VGA1'; | |
EXT_DISPLAY_STATUS=`cat /sys/class/drm/card0-VGA-1/status`; | |
function activate_external() { | |
xrandr --output "$INT_DISPLAY" --off | |
xrandr --output "$EXT_DISPLAY" --auto | |
} | |
function deactivate_external() { | |
xrandr --output "$EXT_DISPLAY" --off | |
xrandr --output "$INT_DISPLAY" --auto | |
} | |
# Main | |
{ | |
if [ "$EXT_DISPLAY_STATUS" == "connected" ]; then { | |
activate_external; | |
} else { | |
deactivate_external; | |
} fi; | |
exit 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment