Skip to content

Instantly share code, notes, and snippets.

@CarlosMecha
Created December 22, 2014 16:22
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 CarlosMecha/20743d60a72ab70b82fd to your computer and use it in GitHub Desktop.
Save CarlosMecha/20743d60a72ab70b82fd to your computer and use it in GitHub Desktop.
Display switch script.
#!/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