Skip to content

Instantly share code, notes, and snippets.

@emrysr
Created October 24, 2020 12:49
Show Gist options
  • Select an option

  • Save emrysr/9361f7225723af7ace740ba1024f10b1 to your computer and use it in GitHub Desktop.

Select an option

Save emrysr/9361f7225723af7ace740ba1024f10b1 to your computer and use it in GitHub Desktop.
create fixed xrandr output mode
/***
* after sleep, ubuntu 20.04 drops down to 1280:1024 ? unable to choose higher resolution from settings.
* create and set new resolution with script
* @see: https://unix.stackexchange.com/questions/227876/how-to-set-custom-resolution-using-xrandr-when-the-resolution-is-not-available-i
**/
# see current list of output options:
$ xrandr
# read settings for given resolution
$ gtf 3840 2160 30
## expected output:
# 3840x2160 @ 30.00 Hz (GTF) hsync: 65.91 kHz; pclk: 339.57 MHz
Modeline "3840x2160_30.00" 339.57 3840 4080 4496 5152 2160 2161 2164 2197 -HSync +Vsync
# create new mode for above output Modeline (name in quotes)
$ xrandr --newmode "3840x2160_30.00" 339.57 3840 4080 4496 5152 2160 2161 2164 2197 -HSync +Vsync
# add new mode to xrandr list under given output
$ xrandr --addmode DP-1 "3840x2160_30.00"
# use the new mode on given oupput (listed in first step)
$ xrandr --output DP-1 --mode "3840x2160_30.00"
script for my graphics output:
!#/bin/bash
# ~/scripts/xreset
PORT="DP-1"
NAME="3840x2160_30.00"
xrandr --newmode "$NAME" 339.57 3840 4080 4496 5152 2160 2161 2164 2197 -HSync +Vsync
xrandr --addmode $PORT "$NAME"
xrandr --output $PORT --mode "$NAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment