• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

debian10调整屏幕分辨率-备忘

武飞扬头像
guohun01
帮助1

xrandr

通过xrandr可以新增分辨率,选择对应的分辨率,控制屏幕的开、关,双屏拓展等等工作:
1.使用cvt生成一个modeline

# cvt 3840 2160
# 3840x2160 59.98 Hz (CVT 8.29M9) hsync: 134.18 kHz; pclk: 712.75 MHz
Modeline "3840x2160_60.00"  712.75  3840 4160 4576 5312  2160 2163 2168 2237 -hsync  vsync

2.使用xrandr里的newmode选项创建一个新mode,参数就用刚刚cvt返回的: 【“3840x2160_60.00” 712.75 3840 4160 4576 5312 2160 2163 2168 2237 -hsync vsync】

# xrandr --newmode "3840x2160_60.00"  712.75  3840 4160 4576 5312  2160 2163 2168 2237 -hsync  vsync

3.将新模式添加到当前输出设备上:

xrandr --addmode DP-1 3840x2160_60.00

其中DP-1就是使用xrandr命令查看到的设备名称:

xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 8192 x 8192
HDMI-1 disconnected primary (normal left inverted right x axis y axis)
DP-1 connected 1920x1080 0 0 (normal left inverted right x axis y axis) 0mm x 0mm
   1920x1080     60.00*   60.00    50.00    59.94    50.00  
   1680x1050     59.95  
   1600x900      60.00  
   1280x1024     75.02    60.02  
   1440x900      59.89  
   1280x960      60.00  
   1152x864      59.96  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    60.00  
   800x600       75.00    60.32  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    60.00    59.94  
   3840x2160_60.00  59.98  
学新通

4.再将刚刚添加的新模式设置为当前分辨率:

xrandr --output DP-1 --mode 3840x2160_60.00

当然前提是,你的显示器支持这个分辨率,如果不支持会报错的。此方法设置分辨率还有一个问题:在机子重启后,上一次设置将失效,需要重新设置,我在网上搜到2种通过编辑shell的办法解决:

  1. 通过定时计划,在开机的时候执行shell代码,重置分辨率的操作:参考自Linux桌面主机添加新的分辨率,定时计划:Linux开机启动、利用crontab实现开机启动某个程序
  2. 在/etc/profile文件里添加对应的代码,参考:在 Linux 上设置新分辨率 - 强制

总之,都是在开机的时候重新执行shell代码,重新设置一遍,当然可能还有其他方法能达到同样的效果,欢迎路过的大神指出。

xorg.conf

还有一种办法,是通过编辑 /etc/X11/xorg.conf的方式永久性的设置分辨率,参考:ubuntu16.04中用xrandr设置屏幕分辨率,且重启后不失效

sudo vim /etc/X11/xorg.conf
复制粘贴以下内容:
Section "Monitor"
Identifier "Configured Monitor"
Modeline "1920x1080_60.00"  173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync  vsync
Option "PreferredMode" "1920x1080_60.00"
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
EndSection
Section "Device"
Identifier "Configured Video Device"
EndSection

保存。重启后就变成 1920x1080了。
学新通

但很多时候,在我们去/etc/X11下去寻找的时候,却找不到对应的xorg.conf文件,网上有对应的办法就是直接创建它,具体的可以参考https://wiki.debian.org/Xorg#Edit_xorg.conf

What if I do not have a xorg config file?

If xorg.conf is missing for some reason, 
Xorg will probe your hardware on every startup.
Though this works fine in most cases, 
some settings remain inaccessible. 
To create a starting point for customization, do the following.

Switch to a console as root (not a terminal emulator in X), then run:

执行:

# /etc/init.d/gdm stop || /etc/init.d/gdm3 stop || /etc/init.d/kdm stop || /etc/init.d/xdm stop || /etc/init.d/lightdm stop
$ cd /etc/X11/
# Xorg -configure

我这边执行stop操作时,提示前面几个文件没有找到,估计是采用的最后一种服务lightdm:

# /etc/init.d/gdm stop || /etc/init.d/gdm3 stop || /etc/init.d/kdm stop || /etc/init.d/xdm stop || /etc/init.d/lightdm stop
bash: /etc/init.d/gdm: 没有那个文件或目录
bash: /etc/init.d/gdm3: 没有那个文件或目录
bash: /etc/init.d/kdm: 没有那个文件或目录
bash: /etc/init.d/xdm: 没有那个文件或目录
[ ok ] Stopping lightdm (via systemctl): lightdm.service.

第三步操作 Xorg -configure时:

/etc/X11$ Xorg -configure
/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server
不是超级用户root,切换后
sudo su
Xorg -configure

(EE) 
Fatal server error:
(EE) Server is already active for display 0
	If this server is no longer running, remove /tmp/.X0-lock
	and start again.
(EE) 
(EE) 
Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
(EE) 

学新通

如果创建失败,提示“创建的屏幕数与检测到的设备数不匹配”,应该怎么办?

据文档所说,最好创建目录 /etc/X11/xorg.conf.d 并在其中放置一些文件以调整隐式 xorg.conf 的部分,例如在此处完成的。
Xorg 从目录 /usr/share/X11/xorg.conf.d 中读取供应商配置信息,如 man xorg.conf.d 所述。

除了在 xorg.conf 中,另一种非常有用的调整 X 设置的方法是在桌面环境的启动时运行的脚本列表中即时调整。

运行 X

startx

但是我这边运行出状况了,以下部分就没有验证了

root@linaro-alip:/# startx


X.Org X Server 1.20.4
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.15.0-128-generic x86_64 Debian
Current Operating System: Linux linaro-alip 4.4.194 #1 SMP Tue Aug 23 06:14:15 UTC 2022 aarch64
Kernel command line: storagemedia=emmc androidboot.storagemedia=emmc androidboot.mode=normal  androidboot.slot_suffix= androidboot.serialno=6d1d0d99595378c3 root=/dev/mmcblk1p9  rw rootwait earlycon=uart8250,mmio32,0xff1a0000 swiotlb=1 console=ttyFIQ0 rootfstype=ext4 coherent_pool=1m
Build Date: 05 March 2019  08:11:12PM
xorg-server 2:1.20.4-1 (https://www.debian.org/support) 
Current version of pixman: 0.36.0
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(  ) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.1.log", Time: Thu Mar  2 15:38:04 2023
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
librga:RGA_GET_VERSION:3.02,3.020000 
ctx=0x558c54e170,ctx->rgaFd=10 
Rga built version:7bf9abf 
(II) modeset(0): Bind output 99 to current crtc 83.
(II) modeset(0): Initializing kms color map for depth 24, 8 bpc.

卡住了
学新通

用户会话可以通过~/.xsessionrc的内容进行配置。可以使用xrandr命令设置屏幕布局和设置。

$ cat .xsessionrc
xrandr --output DVI-I-1 --primary --mode 1600x900 --rate 59.98 --output VGA-1 --mode 1280x1024 --rate 75.02 --right-of DVI-I-1

我这边没有找到.xsessionrc文件。
或者,root可以启动显示管理器,例如kdm、lightdm gdm、gdm3或xdm。

service gdm start
或者
service lightdm start

显示管理器可供多个用户使用。

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgcbfje
系列文章
更多 icon
同类精品
更多 icon
继续加载