Created
December 11, 2017 21:17
-
-
Save xurizaemon/35e91a2be59285e4f813a21f99416049 to your computer and use it in GitHub Desktop.
bash script to arrange monitors to suit various locations
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 | |
## Office | |
# If we find that a screen is connected via docking station VGA, activate it and position it | |
# to the left of the laptop screen. | |
xrandr | grep 'DP-2-3 connected' | ifne xrandr --output DP-2-3 --auto --left-of eDP-1 | |
# If we find that a screen is connected via docking station HDMI, activate it and position it | |
# to the left of the laptop screen, making it primary. | |
xrandr | grep 'DP-2-1 connected' | ifne xrandr --output DP-2-1 --auto --left-of DP-2-3 --primary | |
## Home | |
# If we find that a screen is connected via thunderbolt adapter, activate it and position it | |
# to the left of the laptop screen, making it primary. | |
xrandr | grep 'DP-1 connected' | ifne xrandr --output DP-1 --auto --left-of eDP-1 --primary | |
## Home (old) | |
# If we find that a screen is connected via laptop HDMI-2 port, activate it and position it | |
# to the left of the laptop screen, making it primary. | |
xrandr | grep 'HDMI-2 connected' | ifne xrandr --output HDMI-2 --auto --left-of eDP-1 --primary | |
# If we find that a screen is connected via laptop HDMI-2 port, chillax back to 57Hz or so. | |
# This could probably be cleaned up to test less, and to verify that 1920x1080 is viable. | |
# Also not sure if I need to run --newmode / --addmode each time? | |
xrandr | grep 'HDMI-2 connected' | ifne xrandr --newmode "1920x1080_57.00" 163.00 1920 2040 2240 2560 1080 1083 1088 1119 -hsync +vsync | |
xrandr | grep 'HDMI-2 connected' | ifne xrandr --addmode HDMI-2 "1920x1080_57.00" | |
xrandr | grep 'HDMI-2 connected' | ifne xrandr --output HDMI-2 --mode "1920x1080_57.00" --left-of eDP-1 --primary |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment