Last active
August 7, 2019 06:08
-
-
Save don-smith/49f82f85c1c760e25159f1780af54da2 to your computer and use it in GitHub Desktop.
A script to fix the resolution on Linux machines when the correct resolution isn't detected
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/zsh | |
# This is a shell script that sets up the resolution and position of the | |
# external display monitors. Most computers can figure this stuff out on | |
# their own, but this one can't :( | |
# | |
# How to use this script: | |
# | |
# Run `xrandr` to see a list of displays ports and make note of the one's that are "connected". | |
# As an example, if `DP-1` is on the left, and `HDMI-2` is on the right, | |
# add the following 2 lines to `~/.profile`: | |
# | |
# source ~/fixres.sh | |
# fixres DP-1 HDMI-2 | |
resolution="1920x1080_60.00" | |
createmode() { | |
# This mode line was generated using: cvt 1920 1080 | |
xrandr --newmode $resolution 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync | |
} | |
setdisplay() { | |
[[ $2 == a* ]] && pos="--above" | |
[[ $2 == b* ]] && pos="--below" | |
[[ $2 == l* ]] && pos="--left-of" | |
[[ $2 == r* ]] && pos="--right-of" | |
[[ $2 == s* ]] && pos="--same-as" | |
xrandr --addmode $1 $resolution | |
if [ -n "${2}" ]; then | |
xrandr --output $1 --mode $resolution $pos $3 | |
else | |
xrandr --output $1 --mode $resolution | |
fi | |
} | |
fixres() { | |
createmode | |
setdisplay $1 | |
setdisplay $2 right-of $1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment