xrandr: Your Key to Display Configuration Mastery
Explore the power of xrandr with this comprehensive guide, enabling you to unleash the full potential of your monitor setup. From setting resolutions and managing displays to rotating screens, adjusting refresh rates, and fine-tuning screen positioning, master every aspect of display configuration with xrandr.
Report information about all defined monitors.
xrandr --listmonitors
Report information about currently active monitors
xrandr --listactivemonitors
Report information about the providers available.
xrandr --listproviders
Display Current Monitor Settings
xrandr --current
Set Display Resolution
xrandr --output <display> --mode <resolution>
Add New Mode (Resolution)
cvt 1920 1080 60
xrandr --newmode <Modeline>
xrandr --addmode <display> <mode>
Turn off a Display
xrandr --output <display> --off
Rotate Display
xrandr --output <display> --rotate <orientation>
Reflect Display
xrandr --output <display> --reflect <axis>
Resets all the settings to their defaults
xrandr --auto
Set Refresh Rate
xrandr --output <display> --rate <rate>
Set Primary Monitor
xrandr --output <display> --primary
Scale Display
xrandr --output <display> --scale 1.25x1.25
Panning
xrandr --output <display> --panning 1920x1080
Screen Positioning
xrandr --output <display1> --left-of <display2>
xrandr --output <display1> --right-of <display2>
xrandr --output <display1> --above <display2>
xrandr --output <display1> --below <display2>
Read file on the fly with -0
find /sys -name pmu_name -print0 | xargs -0 cat
Read file and silent the output if we got any errors
find /sys -name pmu_name -exec cat {} + 2>/dev/null
Show xrandr data with verbosity
xrandr --verbose
Query information
xrandr -q
List connected monitors (full output line)
xrandr --query | grep -E '^[A-Z0-9-]+ connected'
List connected monitor names only
xrandr --query | awk '$2=="connected"{print $1}'
Apply a persistent multi-monitor layout at login using xrandr (This is for: HP EliteDesk 800 G3 DM 65W)
#!/bin/sh
sleep 1
xrandr --output HDMI2 --mode 1920x1200 --pos 0x203 --rotate normal 2>/dev/null || true
xrandr --output DP1 --primary --mode 2560x1440 --rate 59.95 --pos 1920x0 --rotate normal 2>/dev/null || true
xrandr --output DP3 --mode 1920x1080 --pos 4480x203 --rotate normal 2>/dev/null || true
xrandr --output DP2 --off 2>/dev/null || true
xrandr --output HDMI1 --off 2>/dev/null || true
Check for wich monitors that is connected and their names
xrandr --verbose | grep -E '^(DP1|DP3|HDMI2)| connected| disconnected|primary'