Date: Thu, 28 Mar 2024 12:31:36 +0000 (UTC) Message-ID: <1525667912.53.1711629096014@fa0ec5443aab> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_52_1380764089.1711629096012" ------=_Part_52_1380764089.1711629096012 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
I use the i3 window manager (i3 forevaa!..).&n= bsp; i3 gets it right here in that it doesn't give you a fancy (shmancy) GU= I application to add new resolutions (hey it's a windows manager not a DE). Pl= us, we can do all that from the CLI anyways...
However, I often find that I need= to add a new resolution particularly when presenting or wanting to connect= my machine to a projector. Last time I needed to do this I couldn't = remember the right syntax for cvt and xrandr= (and had to hang my head in shame as I had to look it up).
I told myself... "self, that's no= t going to happen again" and wrote a quick and dirty bash script to add cus= tom resolutions from the CLI.
First you'll need to meet some requirements:
sudo pacman -S xorg-server x=
org-xrandr
)See below for the quick and dirty bash script. Note this script si= mply allows the user to specify the output device, width, height, and refre= sh rate and it will calculate the CVT mode lines and create/add the resolut= ion to your system.
<=
strong>addresolution (sourced from https://gitlab.jaytaala.com/j.taala/jt-=
config-repo.git) Author Jay Ta'ala Commit d91a8245d2bd22a73895d2d00b957df36012e407 Full path scripts/addresolution Title Merge branch 'develo= pment' |
#!/bin/b= ash showExample() {=20 echo -e "\ne.g. \""$(basename -- "$0")" eDP1 1920 1080 60\"\n" } createRes() { cvt "$WIDTH" "$HEIGHT" "$REFRESH" | grep Modeline | sed "s/Modeline//" = | xargs xrandr --newmode } addRes() { xrandr --addmode "$DEVICE" "$WIDTH"x"$HEIGHT"_"$REFRESH".00 } switchRes() { while true; do read -p "$1" yn case $yn in [Yy]* ) xrandr --output "$DEVICE" --mode "$WIDTH"x"$HEIGHT"_"$R= EFRESH".00 || { echo -e "\nERROR switching resolution with \"xrandr= \"\n" return 1 }; break;; [Nn]* ) break;; * ) echo "Please type \"y\" or \"n\"";; esac done } switchResAnyway() { switchRes "Adding resolution failed. Try to switch to this resolution a= nyway? (y/n) " } switchResNow() { switchRes "Switch to this resolution now? (y/n) " } # check arguments if [ -z "$1" ]; then echo "Please provide an output devide as the first argument" showExample exit 128 fi if [ -z "$2" ]; then echo "Please provide a screen width as the second argument" showExample exit 128 fi if [ -z "$3" ]; then echo "Please provide a screen height as the third argument" showExample exit 128 fi if [ -z "$4" ]; then echo "Please provide a refresh rate as the fourth argument" showExample exit 128 fi #init DEVICE=3D$1 WIDTH=3D$2 HEIGHT=3D$3 REFRESH=3D$4 createRes || { echo -e "\nERROR creating resolution with \"cvt\"\n" switchResAnyway exit 1 } addRes || { echo -e "\nERROR adding resolution with \"xrandr\"\n" switchResAnyway exit 1 } switchResNow exit 0 |
Copy / paste the script into a file using your preferred text editor and=
make it executable. For example, I called my script addre=
solution.sh
so would do
chmod += x addresolution.sh
Now, just execute it with the required arguments (device height width re= fresh-rate), e.g.
./addre= solution.sh eDP1 1280 720 60
Easy(er)!