Ubuntu MATE 24.04系统,使用4K分辨率显示器,lightdm登录界面字体太小。
想通过修改登录界面字体或者分辨率的方式来解决。
修改字体:
1、将/usr/share/glib-2.0/schemas/30_ubuntu-mate.gschema.override文件复制一份/usr/share/glib-2.0/schemas/31_arctica-greeter.gschema.override,这里数字31是/usr/share/glib-2.0/schemas/目录中比其他数字开头的文件名中的数字最大的即可。源文件30_ubuntu-mate.gschema.override在不同版本中可能不一样,找出有[org.ArcticaProject.arctica-greeter]配置项的文件就可以用。
cd /usr/share/glib-2.0/schemas
sudo cp 30_ubuntu-mate.gschema.override 31_arctica-greeter.gschema.override
2、修改arctica-greeter配置文件31_arctica-greeter.gschema.override,可以修改登录界面的背景图片,字体等,修改[org.ArcticaProject.arctica-greeter]节的内容:
sudo vi 31_arctica-greeter.gschema.override
[org.ArcticaProject.arctica-greeter]
修改背景图片:background='/usr/share/backgrounds/cosmos/comet.jpg'
修改字体:font-name='Ubuntu 18'
保存并关闭文件。
3、运行glib-compile-schemas命令
重新编译schema。
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
下次登录时生效。
-------------------------------------------------------------
以上操作只能修改背景图片、登录用户名字体,屏幕分辨率还是太大。
可以尝试使用xrandr命令修改分辨率。我做了以下尝试,但是效果不好,修改完登录界面的分别率后,进入系统,分辨率没有改回来。
1、先解压一份/usr/share/doc/lightdm/lightdm.conf.gz配置文件到/etc/lightdm目录:
cd /etc/lightdm
sudo gzip -cdk /usr/share/doc/lightdm/lightdm.conf.gz | sudo tee lightdm.conf 1>/dev/null
2、修改/etc/lightdm/lightdm.conf文件的display-setup-script配置,注意脚本路径要用绝对路径
:
[Seat:*]
display-setup-script=/etc/lightdm/display-setup-script
3、创建上面路径指导的脚步文件/etc/lightdm/display-setup-script,
sudo vi /etc/lightdm/display-setup-script
内容如下:
#!/bin/bash
monitor=$(xrandr --listactivemonitors | awk 'FNR > 1 {print $4}')
xrandr --output $monitor --mode 2160x1440
增加可执行权限:
sudo chmod +x /etc/lightdm/display-setup-script
下次登录或者重启时分辨率修改成功。
但这种方式有个问题是,这个分辨率会影响到登录系统后,也是同样的分辨率,系统原来配置的分辨率被覆盖了。
为了解决这个问题,参考上面的方式,修改/etc/lightdm/lightdm.conf文件的display-stopped-script也不能生效,其中:
[Seat:*]
display-stopped-script=/etc/lightdm/display-stopped-script
/etc/lightdm/display-stopped-script文件内容如下:
#!/bin/bash
monitor=$(xrandr --listactivemonitors | awk 'FNR > 1 {print $4}')
xrandr --output $monitor --mode 3840x2560
实际测试发现display-stopped-script比display-setup-script先执行。
以上修改分辨率导致进入系统后显示异常,可以通过ctrl + alt + F2按键开启一个TTY终端,将上面的配置恢复,重启系统即可恢复正常。
修改分辨率的方法待进一步研究。
-----------------------------
上面xrandr修改lightdm登录界面分辨率的方式,display-setup-script脚本将
xrandr --output $monitor --mode 2160x1440
命令改为
xrandr --output $monitor --pos 0x0 --scale 0.5x0.5
命令有效(不需要display-stopped-script),登录界面也放大了2倍。但进入系统后,如果显示器设置也配置了放大2倍,就会导致显示异常,因此显示器设置改为自动检测即可。
这么一改,原来WPS显示错位的问题也同时解决了(见Ubuntu MATE系统下WPS显示错位-CSDN博客)。
但是,这种修改方式,显示效果看起来不是那么清晰。
能用,需要再研究。
-----------------------
问题解决:
根据lightdm系统钩子工作机制:
display-setup-script
在X服务器启动后、用户会话/greeter程序运行之前运行。如果需要在X服务器中配置任何特殊内容,请设置此选项。它作为root运行。如果该命令返回错误代码,则X服务器将停止。
display-stopped-script
在X服务器退出后以root身份运行。
greeter-setup-script
是在greeter开始前运行的。它作为root运行。如果该命令返回一个错误代码,引导程序将无法启动(这将导致LightDM停止)。
session-setup-script
在用户会话开始之前运行。如果这个命令返回一个错误,会话将不会启动(用户返回到一个greeter界面)。
session-cleanup-script
在greeter或者用户会话停止时运行,以root身份运行。
session-wrapper
是为会话运行的命令。此命令作为用户运行,需要执行参数中传递的命令以完成会话的运行。如果需要为用户会话进行特殊设置,请使用此选项。注意,默认值是lightdm-session
,因此如果需要覆盖该设置,应该链接到该设置。
greeter-wrapper
是一个运行greeter的命令行。它相当于greeter的session-wrapper
。
作如下配置:
lightdm.conf文件:
#display-setup-script=/etc/lightdm/display-setup-script
#display-stopped-script=/etc/lightdm/display-stopped-script
greeter-setup-script=/etc/lightdm/display-setup-script
session-setup-script=/etc/lightdm/display-stopped-script
session-cleanup-script=/etc/lightdm/display-stopped-script
display-setup-script脚本:
#!/bin/bash
monitor=$(xrandr --listactivemonitors | awk 'FNR > 1 {print $4}')
xrandr --output $monitor --pos 0x0 --scale 0.5x0.5
display-stopped-script脚本:
#!/bin/bash
monitor=$(xrandr --listactivemonitors | awk 'FNR > 1 {print $4}')
xrandr --output $monitor --pos 0x0 --scale 1.0x1.0
按照以上方式配置,lightdm和系统分辨率的问题问题解决了,系统仍然要配置显示器放大200%。(WPS显示错位的问题仍存在,那个问题是显示器设置200%放大导致的。)
实际上,根据钩子机制,将display-setup-script名称改为monitor-zoom-in,而display-stopped-script改为monitor-zoom-restore更合适。另外,session-cleanup-script也不需要配置。
最终配置如下:
lightdm.conf文件:
greeter-setup-script=/etc/lightdm/monitor-zoom-in
session-setup-script=/etc/lightdm/monitor-zoom-restore
monitor-zoom-in脚本:
#!/bin/bash
monitor=$(xrandr --listactivemonitors | awk 'FNR > 1 {print $4}')
xrandr --output $monitor --pos 0x0 --scale 0.5x0.5
monitor-zoom-restore脚本:
#!/bin/bash
monitor=$(xrandr --listactivemonitors | awk 'FNR > 1 {print $4}')
xrandr --output $monitor --pos 0x0 --scale 1.0x1.0
-----------------------
参考:
[SOLVED] change default lightdm screen resolution
How To Configure Your Monitors With Xrandr in Linux - Linux Tutorials - Learn Linux Configuration
xorg - Setting monitor scaling to 200% with xrandr - Ask Ubuntu