Skip to content

Instantly share code, notes, and snippets.

@ThanosDi
Last active May 15, 2019 09:38
Show Gist options
  • Save ThanosDi/085b89dd0cd87f1b7946eeb8c66ecae3 to your computer and use it in GitHub Desktop.
Save ThanosDi/085b89dd0cd87f1b7946eeb8c66ecae3 to your computer and use it in GitHub Desktop.
Turn off or on your second monitor. Second monitor assume its on the right of your main monitor.
#!/bin/bash
monitors=`xrandr --listactivemonitors | head -n1 | cut -d " " -f 2`
if [ "$monitors" == 1 ]
then
`xrandr --output DVI-I-1 --right-of DP-2 --auto` #change DVI-I-1 to your monitor connection running `xrandr`
else
`xrandr --output DVI-I-1 --off` #change DVI-I-1 to your monitor connection running `xrandr`
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment