Created
June 9, 2018 11:04
-
-
Save danixland/6edba6eadba01451290a9d2d4925fae9 to your computer and use it in GitHub Desktop.
bash script to toggle a secondary monitor on or off
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 | |
# DUALHEAD.SH - automatic script that toggles the secondary screen on and off | |
# requires xrandr and optionally feh to set the background image | |
# for the desktop(s). | |
### LVDS1 is the main screen on my laptop | |
### HDMI1 is the secondary screen attached via hdmi and is hanging on the wall | |
### above the laptop | |
# if the file doesn't exists we can assume the secondary screen is off | |
if [[ ! -r /tmp/dualhead ]]; then | |
echo 0 > /tmp/dualhead | |
fi | |
readstatus () { | |
if [[ $(cat /tmp/dualhead) -eq 0 ]]; then | |
startstop start | |
else | |
startstop stop | |
fi | |
} | |
startstop () { | |
case $1 in | |
start ) xrandr --output LVDS1 --mode 1366x768 --output HDMI1 --mode 1360x768 --above LVDS1 | |
source ~/.fehbg | |
echo 1 > /tmp/dualhead | |
;; | |
stop ) xrandr --output HDMI1 --off | |
echo 0 > /tmp/dualhead | |
;; | |
esac | |
} | |
readstatus | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment