【学习笔记】Linux GDM

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

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

Installation

GDM可以与gdm软件包一起安装,并且作为gnome的一部分安装。

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

您可能还希望安装以下内容:

Starting

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#)
Note:

  • 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主题提取到主目录中的文件夹中。 您可以使用以下脚本执行此操作:

extractgst.sh
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
  <gresource prefix="/org/gnome/shell/theme">
    <file>calendar-today.svg</file>
    <file>checkbox-focused.svg</file>
    <file>checkbox-off-focused.svg</file>
    <file>checkbox-off.svg</file>
    <file>checkbox.svg</file>
    <file>dash-placeholder.svg</file>
    <file>gnome-shell.css</file>
    <file>gnome-shell-high-contrast.css</file>
    <file>icons/scalable/status/eye-not-looking-symbolic.svg</file>
    <file>icons/scalable/status/eye-open-negative-filled-symbolic.svg</file>
    <file>icons/scalable/status/message-indicator-symbolic.svg</file>
    <file>icons/scalable/status/keyboard-enter-symbolic.svg</file>
    <file>icons/scalable/status/keyboard-hide-symbolic.svg</file>
    <file>icons/scalable/status/keyboard-layout-filled-symbolic.svg</file>
    <file>icons/scalable/status/keyboard-shift-filled-symbolic.svg</file>
    <file>icons/scalable/status/keyboard-caps-lock-filled-symbolic.svg</file>
    <file>icons/scalable/actions/color-pick.svg</file>
    <file>icons/scalable/actions/pointer-double-click-symbolic.svg</file>
    <file>icons/scalable/actions/pointer-drag-symbolic.svg</file>
    <file>icons/scalable/actions/pointer-primary-click-symbolic.svg</file>
    <file>icons/scalable/actions/pointer-secondary-click-symbolic.svg</file>
    <file>filename</file>
    <file>no-events.svg</file>
    <file>no-notifications.svg</file>
    <file>pad-osd.css</file>
    <file>process-working.svg</file>
    <file>toggle-off-dark.svg</file>
    <file>toggle-off-hc.svg</file>
    <file>toggle-off.svg</file>
    <file>toggle-on-dark.svg</file>
    <file>toggle-on-hc.svg</file>
    <file>toggle-on.svg</file>
  </gresource>
</gresources>

将文件名替换为背景图像的文件名,或删除该行以使用十六进制颜色值。

[En]

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];
}

其中[COLOR]是新的十六进制编码的背景色。

最后,使用以下命令编译主题:

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

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

然后重新启动gdm.service(请注意,仅注销是不够的),您应该发现它正在使用您喜欢的背景图像。

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:

/etc/dconf/profile/gdm
[org/gnome/login-screen]
logo='/path/to/logo.png'

然后重新编译GDM数据库,或者登录到GDM用户并执行以下操作:

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

更改光标主题

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

/etc/dconf/db/gdm.d/10-cursor-settings
[org/gnome/desktop/interface]
text-scaling-factor='1.25'

然后重新编译GDM数据库,或者登录到GDM用户并执行以下操作:

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

此调整禁用在登录屏幕上调整系统音量(通过键盘)时听到的声音反馈。

[En]

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

创建如下文件:

/etc/dconf/db/gdm.d/04-sound
[org/gnome/settings-daemon/plugins/power]
power-button-action='action'

然后重新编译GDM数据库,或者登录到GDM用户并执行以下操作:

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

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

默认情况下,GDM(和GNOME)中禁用了点按单击,但是您可以使用dconf设置轻松启用它。

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:

/etc/dconf/db/gdm.d/06-tap-to-click
[org/gnome/desktop/interface]
toolkit-accessibility='boolean'

然后重新编译GDM数据库,或者登录到GDM用户并执行以下操作:

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

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

要在GDM上启用夜间模式,请运行

$ 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:

~/.dmrc
# Enable automatic login for user
[daemon]
AutomaticLogin=username
AutomaticLoginEnable=True

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

/etc/gdm/custom.conf
XSession=gnome-xorg

如果您想绕过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:

/etc/polkit-1/localauthority.conf.d/org.freedesktop.logind.policy
[User]
SystemAccount=true

一些桌面环境将显示设置存储在 ~/.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">
  <configuration>
    <logicalmonitor>
      ...

      <scale>2</scale>
      ...

      <transform>
        <rotation>right</rotation>
        <flipped>no</flipped>
      </transform>
      ...

    </logicalmonitor>
  </configuration>
</monitors>

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:

GdmXserverTimeout=60

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:

#WaylandEnable=false

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

 [Service]
 Type=idle
 [Service]
 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文章。

删除gdm之后,systemd可能会报告以下内容:

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.

</some>

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

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/10206/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

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