Created
July 14, 2018 23:27
-
-
Save wkalt/89b05cbc045ee47c9854908712692ce5 to your computer and use it in GitHub Desktop.
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 -e | |
## not sure if needed | |
# sleep 0.1 | |
username=wyatt | |
if [[ "$ACTION" == "add" ]]; then | |
DOCKED=1 | |
logger -t DOCKING "Detected condition: docked" | |
elif [[ "$ACTION" == "remove" ]]; then | |
DOCKED=0 | |
logger -t DOCKING "Detected condition: un-docked" | |
else | |
logger -t DOCKING "Detected condition: unknown" | |
echo Please set env var \$ACTION to 'add' or 'remove' | |
exit 1 | |
fi | |
NO_KDM_REBOOT=0 | |
for p in $*; do | |
case "$p" in | |
"NO_KDM_REBOOT") NO_KDM_REBOOT=1 ;; | |
"SWITCH_TO_LOCAL") DOCKED=0 ;; | |
esac | |
done | |
function switch_to_local { | |
export DISPLAY=$1 | |
export XAUTHORITY=/home/wyatt/.Xauthority | |
/usr/bin/xrandr --output DP2-1 --off --output DP2-2 --off | |
/home/wyatt/scripts/keyboard | |
} | |
function switch_to_external { | |
export DISPLAY=$1 | |
export XAUTHORITY=/home/wyatt/.Xauthority | |
/usr/bin/xrandr --output DP2-2 --auto --rotate left --left-of eDP1 | |
/usr/bin/xrandr --output DP2-1 --auto --left-of DP2-2 | |
/home/wyatt/scripts/keyboard | |
} | |
case "$DOCKED" in | |
"0") | |
#undocked event | |
switch_to_local :0 ;; | |
"1") | |
#docked event | |
switch_to_external :0 ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment