Created
September 25, 2014 09:35
-
-
Save Anachron/4a4d2bb922415949e1bb to your computer and use it in GitHub Desktop.
Display Script
This file contains hidden or 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 | |
| oldDisplays="" | |
| while [[ 1 ]] | |
| do | |
| displays=$(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/") | |
| if [[ $displays == $oldDisplays ]] | |
| then | |
| sleep 1 | |
| continue | |
| fi | |
| active=$(xrandr | grep -e " connected [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/") | |
| #primary=$(xrandr| grep -e " primary [^(]" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/") | |
| #connected=$(echo $displays | wc -w) | |
| #echo "Displays: " $displays | |
| #echo "Active: " $active | |
| #echo "Primary:" $primary | |
| oldDisplays=$displays | |
| #echo "Display switch detected." | |
| killall conky 2&> /dev/null | |
| # External, HDMI + VGA | |
| if [[ $active =~ "HDMI1" && $active =~ "VGA1" ]] | |
| then | |
| $(xrandr --output "eDP1" --off) | |
| $(xrandr --output "VGA1" --auto) | |
| $(xrandr --output "HDMI1" --primary --auto) | |
| # External, HDMI | |
| elif [[ $active =~ "HDMI1" ]] | |
| then | |
| $(xrandr --output "eDP1" --off) | |
| $(xrandr --output "VGA1" --off) | |
| $(xrandr --output "HDMI1" --primary --auto) | |
| # External, VGA | |
| elif [[ $active =~ "VGA1" ]] | |
| then | |
| $(xrandr --output "eDP1" --off) | |
| $(xrandr --output "VGA1" --primary --auto) | |
| $(xrandr --output "HDMI1" --off) | |
| # Only one internal | |
| elif [[ $active =~ "eDP1" ]] | |
| then | |
| $(xrandr --output "eDP1" --primary --auto) | |
| $(xrandr --output "VGA1" --off) | |
| $(xrandr --output "HDMI1" --off) | |
| fi | |
| conky -c /home/eos/.conkyrc 2&> /dev/null | |
| sleep 1 | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment