Skip to content

Instantly share code, notes, and snippets.

@Sakib37
Created December 26, 2019 11:02
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 Sakib37/654a94b6cfab993db59c236aa5b21c72 to your computer and use it in GitHub Desktop.
Save Sakib37/654a94b6cfab993db59c236aa5b21c72 to your computer and use it in GitHub Desktop.
Screen resolution setting
Update ~/.profile file as below
# change monitor resolution to 21:9
RESOLUTION_MODE="2560x1080-60.00"
CURRENT_MODE=$(xrandr --current | grep "\*" | awk '{print $1}')
if [ "${CURRENT_MODE}" != "${RESOLUTION_MODE}" ]; then
xrandr --newmode "2560x1080-60.00" 230.76 2560 2728 3000 3440 1080 1081 1084 1118 -HSync +Vsync
xrandr --addmode HDMI-2 "2560x1080-60.00"
fi
################################################ RAW SCRIPT ##################################################
#!/bin/bash
# First we need to get the modeline string for xrandr
# Luckily, the tool "gtf" will help you calculate it.
# All you have to do is to pass the resolution & the-
# refresh-rate as the command parameters:
gtf 2560 1080 60
# In this case, the horizontal resolution is 1920px the
# vertical resolution is 1080px & refresh-rate is 60Hz.
# IMPORTANT: BE SURE THE MONITOR SUPPORTS THE RESOLUTION
# Typically, it outputs a line starting with "Modeline"
# e.g. "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
# Copy this entire string (except for the starting "Modeline")
# Now, use "xrandr" to make the system recognize a new
# display mode. Pass the copied string as the parameter
# to the --newmode option:
xrandr --newmode "2560x1080-60.00" 230.76 2560 2728 3000 3440 1080 1081 1084 1118 -HSync +Vsync
# Well, the string within the quotes is the nick/alias
# of the display mode - you can as well pass something
# as "MyAwesomeHDResolution". But, careful! :-|
# To find using which type of port the monitor is conncted, run
xrandr --props
# Then all you have to do is to add the new mode to the
# display you want to apply, like this for HDMI1 port:
xrandr --addmode HDMI-2 "2560x1080-60.00"
# VGA1 is the display name, it might differ for you.
# Run "xrandr" without any parameters to be sure.
# The last parameter is the mode-alias/name which
# you've set in the previous command (--newmode)
# It should add the new mode to the display & apply it.
# Usually unlikely, but if it doesn't apply automatically
# then force it with this command:
xrandr --output HDMI-2 --mode "2560x1080-60.00"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment