Created
October 3, 2018 16:33
-
-
Save jimrybarski/989aa4afbf176bde7006fe27d9a56266 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 | |
# modified from https://faq.i3wm.org/question/5312/how-to-toggle-onoff-external-and-internal-monitors.1.html | |
# this script will toggle which monitors are on. after booting, all monitors will be clones of the main laptop monitor. | |
# after each execution, we cycle through the following modes: | |
# - external monitor only (work mode) | |
# - external and laptop on but not clones (presentation mode) | |
# - laptop monitor only | |
# we need to include aliases so we can use the commands to adjust screen brightness | |
shopt -s expand_aliases | |
source ~/.aliases | |
EXTERNAL_OUTPUT="HDMI-1" | |
INTERNAL_OUTPUT="eDP-1" | |
# both monitors are on by default after boot | |
if [ ! -f "/tmp/monitor_mode.dat" ] ; then | |
monitor_mode="all" | |
# otherwise read the value from the file | |
else | |
monitor_mode=`cat /tmp/monitor_mode.dat` | |
fi | |
if [ $monitor_mode = "all" ]; then | |
monitor_mode="EXTERNAL" | |
day | |
xrandr --output $INTERNAL_OUTPUT --off --output $EXTERNAL_OUTPUT --auto | |
elif [ $monitor_mode = "EXTERNAL" ]; then | |
monitor_mode="PRESENTATION" | |
projector | |
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto --left-of $INTERNAL_OUTPUT | |
else | |
monitor_mode="all" | |
night | |
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off | |
fi | |
echo "${monitor_mode}" > /tmp/monitor_mode.dat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment