【学习笔记】Linux GDM

From GDM – GNOME Display Manager: “The GNOME Display Manager (GDM)是管理图形显示服务器并处理图形用户登录的程序.”

显示管理器为X Window System和Wayland用户提供图形化登录提示.



如果您希望使用GNOME 2中使用的旧版GDM,并拥有自己的配置实用程序,请安装gdm-oldAUR软件包。 请注意,除非另有说明,否则本文的其余部分将讨论当前的GDM,而不是旧版GDM。



To start GDM at boot time enable gdm.service.

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png
Reason: this works only with X desktop environments (Discuss in Talk:GDM#GDM with wayland does not use xprofile for autostarting)
One might want to autostart certain commands, such as xrandr for instance, on login. This can be achieved by adding a command or script to a location that is sourced by the display manager. See Display manager#Autostarting for a list of supported locations.

Note: The /etc/gdm/Init directory is no longer a supported location, see [1].

The factual accuracy of this article or section is disputed.

Reason: Configuration is not persistent and will be gone after gdm update. Needs to be rewritten to enable user-themes gnome-shell extension for gdm user and use custom theme and set gsetting to use that theme (Discuss in Talk:GDM#)

  • Since GNOME 3.16, GNOME Shell themes are now stored as binary files (gresource).

  • This change will be overwritten on subsequent updates of gnome-shell.

首先,您需要将现有的GNOME Shell主题提取到主目录中的文件夹中。 您可以使用以下脚本执行此操作:

<?xml version="1.0" encoding="UTF-8"?>
  <gresource prefix="/org/gnome/shell/theme">



Replace the file name with the file name of the background image, or delete the line to use hexadecimal color values instead.

现在,打开目录中的 gnome-shell.css文件,并如下更改 #lockDialogGroup定义:

#lockDialogGroup {
  background: url(filename);
  background-size: [WIDTH]px [HEIGHT]px;
  background-repeat: no-repeat;

background-size设置为GDM使用的分辨率,这不一定是图像的分辨率。 有关显示分辨率的列表,请参阅显示分辨率。 同样,将filename设置为背景图像的名称。

如果只想更改背景颜色,请按如下所示调整 #lockDialogGroup的定义:

#lockDialogGroup {
  background-color: #[COLOR];



$ glib-compile-resources gnome-shell-theme.gresource.xml

然后将生成的 gnome-shell-theme.gresource 文件复制到 /usr/share/gnome-shell 文件夹.


DConf 配置

一些GDM设置存储在DConf数据库中。. They can be configured either by adding keyfiles to the /etc/dconf/db/gdm.d directory 然后以root身份运行 dconf update或登录系统上的GDM用户并使用gsettings命令行工具直接更改设置来重新编译GDM数据库。

Note that for the former approach, a GDM profile file is required – this must be created manually as it is no longer shipped upstream, see below:



$ gsettings set org.gnome.login-screen logo '/path/to/logo.png'


GDM忽略GNOME光标主题设置,并且也忽略了根据XDG规范的光标主题设置。 要更改GDM中使用的光标主题,请创建以下关键文件



$ gsettings set org.gnome.desktop.interface text-scaling-factor '1.25'



This adjustment disables the sound feedback you hear when adjusting the system volume (through the keyboard) on the login screen.




$ gsettings set org.gnome.settings-daemon.plugins.power power-button-action 'action'

where action can be one of nothing, suspend or hibernate.


Note: If you want to do this under X, you have to first set up correct X server access permissions – see #Configure X server access permission.

To enable tap-to-click, either create the following keyfile:



$ gsettings set org.gnome.desktop.interface toolkit-accessibility 'boolean'

The menu is disabled when the key is false, enabled when it is true.


$ sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true

Keyboard layout

系统键盘布局将应用于GDM. See Keyboard configuration in Xorg#Using X configuration files.

Tip: See Wikipedia:ISO 3166-1 for a list of keymaps.
If a system has multiple users, it is possible to specify a keyboard layout for GDM to use which is different from the system keyboard layout. Firstly, ensure the package gnome-control-center is installed. Then start gnome-control-center and navigate to Region & Language -> Input Sources. In the header bar, hit the Login Screen toggle button and then choose a keyboard layout from the list. Note that the Login Screen button will not be visible in the header bar unless multiple users are present on the system [5].

Users of GDM 2.x (legacy GDM) may need to edit ~/.dmrc as shown below:

# Enable automatic login for user

Tip: &#x5982;&#x679C;&#x6DFB;&#x52A0;&#x8FD9;&#x4E9B;&#x884C;&#x540E;GDM&#x5931;&#x8D25;&#xFF0C;&#x8BF7;&#x4ECE;TTY&#x4E2D;&#x5C06;&#x5176;&#x6CE8;&#x91CA;&#x6389;&#x3002;.


如果您想绕过GDM中的密码提示,则只需将以下行添加到 /etc/pam.d/gdm-password:

auth sufficient pam_succeed_if.so user ingroup nopasswdlogin

然后,将 nopasswdlogin组添加到您的系统。 See User group for group descriptions and group management commands.

现在,将您的用户添加到 nopasswdlogin组,您只需单击用户名即可登录。

Warning:</p> <ul> <li>不要对root帐户执行此操作。</li> <li>You won't be able to change your session type at login with GDM anymore. If you want to change your default session type, you will first need to remove your user from the <code>nopasswdlogin</code> group.

GDM uses polkit and logind to gain permissions for shutdown. You can shutdown the system when multiple users are logged in by setting:


一些桌面环境将显示设置存储在 ~/.config/monitors.xml. xrandr commands are then generated on the base of the file content. GDM has a similar file stored in /var/lib/gdm/.config/monitors.xml.

If you have your monitors setup as you like (resolution, refresh rate, orientation, scaling, primary and so on) in ~/.config/monitors.xml and want GDM to honor those settings:

# cp ~/.config/monitors.xml /var/lib/gdm/.config/
# chown gdm:gdm /var/lib/gdm/.config/monitors.xml

The relevant parts of monitors.xml for screen rotation and scaling are:

<monitors version="2">




Changes will take effect on logout. This is necessary because GDM does not respect xorg.conf.

Note: If you use GDM under Wayland, you must also use a monitors.xml that was created under Wayland. See GDM bug 224 for more info. Alternatively, you can force GDM to #Use Xorg backend, and use a monitors.xml that was created under Xorg.
Note: If you use fractional scaling, you need to enable it for user gdm.

配置X server 访问权限

You can use the xhost command to configure X server access permissions.

For instance, to grant GDM the right to access the X server, use the following command:

# xhost +SI:localuser:gdm


GDM doesn’t work well in Wayland mode with the proprietary NVIDIA driver. When using this driver, GDM will use Xorg instead.[7]

To force-enable Wayland, disable the udev rule responsible for disabling Wayland in GDM:

# ln -s /dev/null /etc/udev/rules.d/61-gdm.rules

If GDM starts up properly on boot, but fails after repeated attempts on logout, try adding this line to the daemon section of /etc/gdm/custom.conf:


See Xorg#Rootless Xorg.

The Wayland backend is used by default, and the Xorg backend is used only if the Wayland backend cannot be started. You may wish to use the Xorg backend instead if, for example:

The screen flickers
GDM crashes
To use the Xorg backend by default, uncomment the following line in /etc/gdm/custom.conf:


引导后,GDM可能会为您显示黑屏,并且左上方的白色光标闪烁。 这可能是由于GDM在完全初始化图形驱动程序之前启动而引起的。 一种可能的解决方法是尽早启动KMS。 另一个可能的解决方法是编辑systemd服务,并将其类型设置为” idle”或添加一个小的延迟:

 ExecStartPre=/bin/sleep 2

If a longer delay is required, increase the delay time.

如果在引导后屏幕保持黑色,并且直到移动鼠标或在键盘上键入内容后GDM才启动,则可能是由于缺少生成随机数所需的熵。 要确认,请检查以下行是否出现在systemd-random-seed的日志中(可以使用读取 journalctl --unit systemd-random-seed):

Kernel entropy pool is not initialized yet, waiting until it is.

为了解决这个问题,如果您的CPU支持RDRAND指令,则可以传递 random.trust_cpu = on内核参数,或者您也可以使用hadged来提供熵,尽管它的质量很低。 有关其他解决方案,请参见有关该主题的Debian文章。


user 'gdm': directory '/var/lib/gdm' does not exist

要删除此警告,请以root用户身份登录并删除主要用户 gdm,然后删除组 gdm

# userdel gdm
# groupdel gdm

Verify that gdm is successfully removed via pwck and grpck. To round it off, you may want to double-check no unowned files for gdm remain.

GDM uses a separate dconf database to control power management. To apply your user’s power settings, copy them to GDM’s dconf database:

$ IFS=$'\n'; for x in $(sudo -u username gsettings list-recursively org.gnome.settings-daemon.plugins.power); do eval "sudo -u gdm dbus-launch gsettings set $x"; done; unset IFS

where username is your username.

To only disable auto-suspend on AC, run:

$ sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'

(To also disable auto-suspend on battery, run the command with battery instead of ac.)

Restart GDM to activate your changes.

Wayland requires Kernel Mode Setting (KMS) running in order to work, and on some machines the GDM process start earlier than KMS, resulting in GDM unable to see Wayland and working only with X.Org. This might result in messages like the following showing up in your log:

gnome-shell[569]: Failed to open gpu '/dev/dri/card0': GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Operation not permitted
gnome-shell[569]: Failed to create backend: No GPUs found
systemd[505]: gnome-shell-wayland.service: Failed with result 'protocol'.

systemd[505]: Failed to start GNOME Shell on Wayland.

Alternatively, the same issue may lead to GDM not appearing or monitor only displaying the TTY output.

You can solve this problem by starting KMS earlier.

Also, if you use a NVIDIA driver, the Wayland session might be blocked by a udev rule (see the notes under GNOME#Wayland sessions). This might result in messages like the following:

systemd[1022]: Condition check resulted in GNOME Shell on Wayland being skipped.

systemd[1022]: org.gnome.Shell@wayland.service: Skipped due to 'exec-condition'.

systemd[1022]: org.gnome.Shell@wayland.service: Control process exited, code=exited, status=2/INVALIDARGUMENT

In this case, you might see lines like this in /usr/lib/udev/rules.d/61-gdm.rules:

# disable Wayland when using the proprietary nvidia driver
DRIVER=="nvidia", RUN+="/usr/lib/gdm-disable-wayland"

To let GDM use Wayland, copy 61-gdm.rules from /usr/lib/udev/rules.d/ to /etc/udev/rules.d/ (where the latter file will override the former) and comment out the related line:

# DRIVER=="nvidia", RUN+="/usr/lib/gdm-disable-wayland"

At first, without an NVidia device, GDM starts and works normally on Wayland, but stops working once an NVidia eGPU is plugged in (or the nvidia module is loaded for other reasons). A typical symptom of the problem is a black screen with a blinking cursor upon logouts and GDM restarts and the following message in GDM’s logs (journalctl -u gdm -b):

Gdm: Child process -<some pid> was already dead.


The solution is the same as above: Prevent /usr/lib/gdm-disable-wayland from running upon nvidia module loading.

Notice that GDM on Wayland will no longer work once /usr/lib/gdm-disable-wayland has run. This is because WaylandEnable=false has been written into /run/gdm/custom.conf, which overrides /etc/gdm/custom.conf. To fix the situation without a reboot, remove /run/gdm/custom.conf and then restart GDM.

Original: https://www.cnblogs.com/nightnine/p/14696471.html
Author: dozeoo
Title: 【学习笔记】Linux GDM





最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总