Skip to content

Instantly share code, notes, and snippets.

@GiorgioAresu
Created May 6, 2018 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GiorgioAresu/d2edd695ff88faa0484508d7398ba6fe to your computer and use it in GitHub Desktop.
Save GiorgioAresu/d2edd695ff88faa0484508d7398ba6fe to your computer and use it in GitHub Desktop.
Script to add a custom resolution when it doesn't get detected automatically (ie. ultrawide)
#!/bin/bash
if [ $# -lt 5 ]
then
echo "Usage: $0 (add|del) display hres vres refresh"
exit 1
fi
mode=$1
display=$2
hres=$3
vres=$4
ref=$5
modename=$(cvt $hres $vres $ref|sed -n '2p'|cut -d\ -f2)
modeline=$(cvt $hres $vres $ref|sed -n '2p'|cut -d\ -f2-)
if [ $mode == "add" ]
then
xrandr --newmode $modeline
xrandr --addmode $display $modename
echo "To set mode, use: xrandr --output $display --mode $modename"
elif [ $mode == "del" ]
then
xrandr --delmode $display $modename
xrandr --rmmode $modename
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment