使用xrandr命令设置Ubuntu系统分辨率

From time to time I see posts on various Linux forums asking how to set a screen resolution.

Often this results in a discussion about writing a configuration file, xorg.conf ( /etc/X11/xorg.conf )

While there is nothing wrong with writing a xorg.conf, xorg.conf is depreciated and writing an xorg.conf is intimidating to many users.

Using xrandr is potentially faster and easier.

How to use xrandr

First display a list of your monitor resolutions

xrandr -q

Note: If you do not see the resolution you desire listed, either your monitor does not support that particular resolution or you may need to install a driver (ati, intel, or nvidia are the big 3). The technical details of installing these drivers varies by graphics card and will not be covered in this blog.

Then set the resolution you want to use (change the “1400×1050″ to your desired resolution).

xrandr -s 1400x1050

Adjusting the dpi (dots per inch)

dpi refers to the resolution of your monitor (pixels per inch) and affects window decorations, window size, and font. See this page for additional information.

On many monitors xrandr will set the dpi automatically. When it does not, or if you prefer an alternate setting, you can try specifying a dpi manually.

xrandr --dpi 96 -s 1400x1050

If that fails, you can specify a dpi in ~/.Xdefaults

Open any editor and enter the following configuration:

Xft.dpi: 96

This dpi will then be applied to any new windows you open. Alternately you can log off and back on (no need to reboot).

If 96 is not the right size for your, try a smaller ( 72 ) or larger ( 135 ) value.

Dual monitors

To use xrandr to configure dual monitors, use the --right-of or --left-of options.

Example, using a nvidia card:

First list your monitors with xrandr, note the monitor names (in bold).

bodhi@zenix:~$ xrandr -q
Screen 0: minimum 320 x 200, current 1920 x 1200, maximum 4096 x 4096
DVI-I-1 connected 1920x1200+0+0 (normal left inverted right x axis y axis) 520mm x 320mm
1920×1200 60.0*+
1600×1200 60.0
1680×1050 60.0
1280×1024 75.0
1280×960 60.0
1152×864 75.0
1024×768 75.1 70.1 60.0
832×624 74.6
800×600 72.2 75.0 60.3 56.2
640×480 72.8 75.0 60.0
720×400 70.1
DVI-I-2 connected 1920x1200+0+0 (normal left inverted right x axis y axis) 520mm x 320mm
1920×1200 60.0*+
1600×1200 60.0
1680×1050 60.0
1280×1024 75.0
1280×960 60.0
1152×864 75.0
1024×768 75.1 70.1 60.0
832×624 74.6
800×600 72.2 75.0 60.3 56.2
640×480 72.8 75.0 60.0
720×400 70.1
TV-1 disconnected (normal left inverted right x axis y axis)

Use xrandr to configure the monitors. Change the names “DVI-I-1″ and “DVI-I-2″ to the names of your monitors. You may also need to adjust the resolution and change “--left-of to” “--right-of”

xrandr --auto --output DVI-I-2 --mode 1920x1200 --left-of DVI-I-1

Has the same effect as

xrandr --auto --output DVI-I-1 --mode 1920x1200 --right-of DVI-I-2

Set a primary display

To set a primary display, use the --primary option.

xrandr --auto --output DVI-I-1 --mode 1920x1200 --primary --right-of DVI-I-2

Configuring xrandr to run when you log in

The method to do this varies by desktop and with most major desktop environments (gnome, kde, xfce) you would add the xrandr command to your start up options / applications.

With openbox, add the xrandr command to ~/.config/openbox/autostart.sh.

With fluxbox, use ~/.fluxbox/startup

Alternately, depending on your window manager, you can add the xrandr command to ~/.xinit

For a link on using ~/.xinit, see this fluxbox wiki page or, as an alternate, the Arch wiki Slim page.

Graphical tools

I am aware of 3 5 (thanks to charlie-tca and KenP) graphical font ends for xranadr : lxrandr , grandr, the grandr appletARandR, and Krandr.

lxrandr is a part of the lxde and is lightweight and fast, but does not have all of the xrandr options available.

grandr has more a few more options, including rotation, but again not all the xrandr options are available from the graphical interface.

grandr applet is a small application (gnome applet) that would run in your panel and similar to lxrandr allows one to set a resolution.

Krandr is a KDE applet to set your resolution.

arandr is similar to grandr, but IMO the interface seems less intuitive. Arandr will write a script for you to set your resolution at login.

For additional information on using xrandr, see the xrandr man page.

### 设置 Ubuntu 屏幕分辨率 对于希望调整 Ubuntu 系统屏幕分辨率的用户来说,存在多种途径来实现这一目标。具体操作取决于所使用Ubuntu 版本以及个人偏好。 #### 使用图形界面设置分辨率 对于较新版本的 Ubuntu (17.0 及以上),可以直接通过图形化界面完成配置: 进入系统的“显示设置”(Display Settings)选项,在这里可以直观地看到当前可用的不同分辨率列表,并允许从中挑选最合适的分辨率进行应用[^2]。 如果发现所需的具体分辨率不在可选范围内,则可能需要进一步手动添加新的模式。 #### 命令行工具 `xrandr` 的使用 另一种更为灵活的方式是利用命令行工具 `xrandr` 来查看和支持自定义分辨率设定。首先可以通过运行简单的命令获取有关连接显示器的信息及其支持的所有分辨率: ```bash xrandr ``` 上述命令会列出所有已识别到的输出设备名称(如 HDMI-1, eDP-1),并附带它们各自支持的最大和最小分辨率范围以及其他参数信息。 当确认好要更改的目标分辨率后,比如想要切换成 1920×1080 分辨率的话,只需执行如下指令即可生效: ```bash xrandr -s 1920x1080 ``` 需要注意的是,某些情况下直接指定的标准分辨率可能会因硬件兼容性问题而无法正常工作;这时就需要创建一个新的视频模式并通过特定语法将其加入现有模式库中再做选择。例如针对虚拟环境中的情况,有建议提到可以在 `/etc/profile` 文件里追加一段脚本来固定新增一种非标准但适合实际需求的高宽比例组合[^3]: ```bash sudo vim /etc/profile # 添加以下两行代码 xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync xrandr --addmode Virtual1 "1920x1080_60.00" source /etc/profile ``` 这种方法特别适用于那些在启动过程中未能自动检测到最佳匹配项的情况。 #### 验证与保存修改后的设置 无论采用哪种方式进行调整,都应当重启计算机或注销重登录一次以确保变更被正确加载。另外还可以考虑将这些个性化定制纳入开机初始化流程之中以便长期维持稳定状态。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值