Linux中 xrandr 单显、双显配置
xrandr是RandR(调整大小和旋转)X 窗口系统扩展的官方配置实用程序。可用于设置屏幕输出的大小、方向、配置多台显示器的克隆和扩展等。
通过 xrandr 可查看连接屏幕信息;执行之前可先使用以下命令进行设置显示服务器:
export DISPLAY=:0
xrandr
单屏幕显示
#旋转屏幕
xrandr -o left # 向左旋转90度
xrandr -o right # 向右旋转90度
xrandr -o normal # 回到正常角度
#设置分辨率
xrandr -s 1024x768 #设置分辨率
#设置刷新率
xrandr -rate 60 #设置刷新率
双屏幕显示
克隆
#复制屏幕,两块屏幕显示一致:
xrandr --output HDMI-1 --same-as DP-1 --auto
扩展
#DP-1为主显示屏,HDMI显示为DP-1的扩展屏且在其右边
xrandr --output HDMI-1 --right-of DP-1 --auto
#--output HDMI-1 表示设置 HDMI-1 这个显示输出端口的参数,--right-of DP-1 表示将 HDMI-1 设置在 DP-1 的右边。 #--auto 表示自动选择最佳分辨率和刷新率
#DP-1为主显示屏,HDMI显示为DP-1的扩展屏且在其左边
xrandr --output HDMI-1 --left-of DP-1 --auto
#DP-1为主显示屏,HDMI显示为DP-1的扩展屏且在其上面
xrandr --output HDMI-1 --above DP-1 --auto
#DP-1为主显示屏,HDMI显示为DP-1的扩展屏且在其下面
xrandr --output HDMI-1 --below DP-1 --auto
#设定 HDMI-1 为主显示器.
xrandr --output HDMI-1 --auto --primary
#关闭 DP-1 显示器
xrandr --output DP-1 --off
三屏幕显示
克隆
连接屏幕:HDMI-1 HDMI-2 DP-1
克隆配置命令:
xrandr --output DP-1 --same-as HDMI-1
xrandr --output HDMI-1 --same-as HDMI-2
扩展
连接屏幕分辨率:
DP-1 :1920x1080 HDMI-1: 1920x1080 HDMI-2: 1920x1080
按照从左到右的顺序连接,–auto 选项表示根据显示器的默认分辨率自动设置,而 --pos 选项用于指定每个显示器在屏幕上的位置。
拓展配置命令:
xrandr --output DP-1 --auto --pos 0x0 --output HDMI-1 --auto --pos 1920x0 --output HDMI-2 --auto --pos 3840x0