1、显示器检测: xrandr 可以用于检测并列出连接到计算机的显示器和显示器接口,包括 VGA、HDMI、DisplayPort 等。它会显示显示器的名称、分辨率、刷新率等信息。
2、分辨率设置: 可以使用 xrandr 命令来动态更改显示器的分辨率,以适应不同的需求。这对于多显示器设置、投影仪设置或应对显示器支持的不同分辨率非常有用。
3、分辨率模式: xrandr 允许指定特定的分辨率模式。这是重要的,因为不同的显示器和显卡可能支持不同的分辨率和刷新率模式。可以使用 -mode 选项来指定特定的模式。
4、屏幕布局: xrandr 允许配置多个显示器的位置和布局。可以设置它们的相对位置,使它们成为一个扩展的屏幕或克隆屏幕。这对于多显示器工作环境非常有用。
5、旋转和变换: xrandr 支持屏幕旋转、翻转以及变换操作。这允许根据需要进行显示器方向的更改,例如将显示器旋转为竖屏模式。
6、模式参数: 可以使用 xrandr 来设置和调整模式参数,包括刷新率、频率和位深度。这对于对显示器性能和质量有要求的专业应用程序非常重要。
7、脚本和自动化: xrandr 可以与脚本一起使用,以自动配置显示器和分辨率,适应特定环境或任务。这对于系统管理员和自动化任务非常有用。
8、调试和故障排除: 可以使用 xrandr 来诊断和解决与显示器设置相关的问题,如不正确的分辨率、显示器未识别等。
--auto #以系统最大分辨率输出
--off #指定设备设置为关闭
--output #输出设备
--mode #设置分辨率
--rate #设置刷新率
[zhouyong@localhost ~]$ xrandr --help
usage: xrandr [options]
where options are:
--display <display> or -d <display> 显示器信息
--help 帮助信息
-o <normal,inverted,left,right,0,1,2,3>
or --orientation <normal,inverted,left,right,0,1,2,3>
-q or --query 查询
-s <size>/<width>x<height> or --size <size>/<width>x<height> 分辨率
-r <rate> or --rate <rate> or --refresh <rate>
-v or --version 版本信息
-x (reflect in x)
-y (reflect in y)
--screen <screen> 显示信息
--verbose 详细信息
--current 当前屏幕信息
--dryrun
--nograb
--prop or --properties
--fb <width>x<height>
--fbmm <width>x<height>
--dpi <dpi>/<output>
--output <output>
--auto
--mode <mode>
--preferred
--pos <x>x<y>
--rate <rate> or --refresh <rate>
--reflect normal,x,y,xy
--rotate normal,inverted,left,right
--left-of <output>
--right-of <output>
--above <output>
--below <output>
--same-as <output>
--set <property> <value>
--scale <x>x<y>
--scale-from <w>x<h>
--transform <a>,<b>,<c>,<d>,<e>,<f>,<g>,<h>,<i>
--off
--crtc <crtc>
--panning <w>x<h>[+<x>+<y>[/<track:w>x<h>+<x>+<y>[/<border:l>/<t>/<r>/<b>]]]
--gamma <r>:<g>:<b>
--brightness <value>
--primary
--noprimary
--newmode <name> <clock MHz>
<hdisp> <hsync-start> <hsync-end> <htotal>
<vdisp> <vsync-start> <vsync-end> <vtotal>
[flags...]
Valid flags: +HSync -HSync +VSync -VSync
+CSync -CSync CSync Interlace DoubleScan
--rmmode <name>
--addmode <output> <name>
--delmode <output> <name>
--listproviders
--setprovideroutputsource <prov-xid> <source-xid>
--setprovideroffloadsink <prov-xid> <sink-xid>
--listmonitors
--listactivemonitors
--setmonitor <name> {auto|<w>/<mmw>x<h>/<mmh>+<x>+<y>} {none|<output>,<output>,...}
--delmonitor <name>
[zhouyong@localhost ~]$ xrandr --currentScreen 0: minimum 16 x 16, current 1718 x 926, maximum 32767 x 32767XWAYLAND0 connected 1712x926+0+0 (normal left inverted right x axis y axis) 0mm x 0mm1712x926 59.88*+1152x864 59.961024x768 59.92800x600 59.86640x480 59.38320x240 59.521440x900 59.891280x800 59.81720x480 59.71640x400 59.95320x200 58.961600x900 59.951368x768 59.881280x720 59.861024x576 59.90864x486 59.92720x400 59.55640x350 59.77[zhouyong@localhost ~]$
--right-of #主显示器右侧
--left-of #主显示器左侧
--above #主显示器上方
--below #主显示器下方
# If an external monitor is connected, place it with xrandr
# External output may be "VGA" or "VGA-0" or "DVI-0" or "TMDS-1"
EXTERNAL_OUTPUT="VGA" //扩展屏
INTERNAL_OUTPUT="LVDS" //主屏
# EXTERNAL_LOCATION may be one of: left, right, above, or below
EXTERNAL_LOCATION="right"
case "$EXTERNAL_LOCATION" in
left|LEFT)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;
right|RIGHT)
EXTERNAL_LOCATION="--right-of $INTERNAL_OUTPUT"
;;
top|TOP|above|ABOVE)
EXTERNAL_LOCATION="--above $INTERNAL_OUTPUT"
;;
bottom|BOTTOM|below|BELOW)
EXTERNAL_LOCATION="--below $INTERNAL_OUTPUT"
;;
*)
EXTERNAL_LOCATION="--left-of $INTERNAL_OUTPUT"
;;esac
xrandr | grep $EXTERNAL_OUTPUT | grep " connected "
if [ $? -eq 0 ]; then
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION
# Alternative command in case of trouble:
# (sleep 2; xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --auto $EXTERNAL_LOCATION) &
else
xrandr --output $INTERNAL_OUTPUT --auto --output $EXTERNAL_OUTPUT --off
fi