Last active
August 26, 2018 21:21
-
-
Save xurizaemon/e1892192ea8dd03a210d2890f8f966e7 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 | |
# Unity doesn't remember my screen layouts, so I made this to do it for me. | |
# | |
# https://gist.github.com/e1892192ea8dd03a210d2890f8f966e7 | |
# | |
# GPLv3+, (c) Chris Burgess @xurizaemon | |
# | |
# To update on gist.github.com: | |
# `gist -u https://gist.github.com/e1892192ea8dd03a210d2890f8f966e7 ~/bin/x-displays.sh` | |
CONNECTED=$( xrandr | grep ' connected' ) | |
LAYOUT=unknown | |
if [[ $CONNECTED = *"DP-2-1"* ]] ; then | |
if [[ $CONNECTED = *"DP-2-2"* ]] ; then | |
LAYOUT=dock_displayport_both | |
fi | |
elif [[ $CONNECTED = *"DP-2-3"* ]] ; then | |
if [[ $CONNECTED = *"DP-2-1"* ]] ; then | |
LAYOUT=dock_vga_hdmi | |
fi | |
elif [[ $CONNECTED = *"HDMI-2 connected"* ]] ; then | |
LAYOUT=hdmi-2 | |
elif [[ $CONNECTED = *"DP-1 connected"* ]] ; then | |
LAYOUT=thunderbolt | |
fi | |
case "$LAYOUT" in | |
"dock_displayport_both") | |
# Displayport 1, 2, laptop | |
xrandr --output DP-2-2 --auto --left-of eDP-1 | |
xrandr --output DP-2-1 --auto --left-of DP-2-2 --primary | |
echo "Configured for $LAYOUT" | |
;; | |
"dock_vga_hdmi") | |
# HDMI, VGA, laptop | |
xrandr --output DP-2-3 --auto --left-of eDP-1 | |
xrandr --output DP-2-1 --auto --left-of DP-2-3 --primary | |
echo "Configured for $LAYOUT" | |
;; | |
"thunderbolt") | |
# Thunderbolt, laptop | |
xrandr --output DP-1 --auto --left-of eDP-1 --primary | |
echo "Configured for $LAYOUT" | |
;; | |
"hdmi-2") | |
# Set to 57Hz for monitor support | |
xrandr --newmode "1920x1080_57.00" 163.00 1920 2040 2240 2560 1080 1083 1088 1119 -hsync +vsync | |
xrandr --addmode HDMI-2 "1920x1080_57.00" | |
# HDMI, laptop | |
xrandr --output HDMI-2 --mode "1920x1080_57.00" --left-of eDP-1 --primary | |
echo "Configured for $LAYOUT" | |
;; | |
*) | |
echo "Layout $LAYOUT not known." | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment