Skip to content

Instantly share code, notes, and snippets.

@Himura2la
Last active October 15, 2020 21:34
Show Gist options
  • Save Himura2la/a3c2ba0f3664e1e60dcd15d1b1c240e1 to your computer and use it in GitHub Desktop.
Save Himura2la/a3c2ba0f3664e1e60dcd15d1b1c240e1 to your computer and use it in GitHub Desktop.
Add a resolution to "Unknown Display"
#!/bin/sh
get_xorg_conf() {
local usage="Usage: ${FUNCNAME[0]} monitor horizontal_resolution vertical_resolution refresh_rate"
local mon=${1?$usage}
local X=${2?$usage}
local Y=${3?$usage}
local refresh=${4?$usage}
local cvt="$(cvt $X $Y $refresh)"
local mode_line="$(echo "$cvt" | grep '^[^#]')"
local mode_name="$(echo "$modeline" | cut -d' ' -f2)"
# WARNING: Mixed tabs and spaces below
cat <<-EOF
Section "Monitor"
Identifier "$mon"
$mode_line
Option "PreferredMode" $mode_name
EndSection
EOF
}
@Himura2la
Copy link
Author

Himura2la commented Oct 15, 2020

Usage:

. <(wget -O- https://gist.githubusercontent.com/Himura2la/a3c2ba0f3664e1e60dcd15d1b1c240e1/raw)

xrandr --listactivemonitors
Monitors: 2
 0: +*LVDS-1 1366/344x768/194+0+0  LVDS-1
 1: +VGA-1 1024/271x768/203+1366+0  VGA-1

get_xorg_conf VGA-1 1280 1024 60 | sudo tee /etc/X11/xorg.conf.d/10-monitor.conf
Section "Monitor"
    Identifier "VGA-1"
    Modeline "1280x1024_60.00"  109.00  1280 1368 1496 1712  1024 1027 1034 1063 -hsync +vsync
    Option "PreferredMode" 
EndSection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment