GDM (简体中文)
来自GDM - GNOME显示管理器:“GNOME显示管理器(GDM)是一个管理图形显示服务并处理图形用户登录的程序。
显示管理器为X Window System和Wayland提供图形登录提示。
安装
可通过安装gdm包来安装GDM,或作为gnome组的一部分安装。
启动
若要开机启动GDM,启用gdm.service
。
自动启动应用
To automatically start applications after logging in, follow the instructions in Autostarting#On desktop environment startup that pertain to your desktop environment.
配置
登录页面背景图片
- 自GNOME 3.16开始,GNOME Shell主题被存储为二进制文件(gresource)。
- This change will be overwritten on subsequent updates of gnome-shell.
首先,您需要将现有的 GNOME Shell 主题解压到您的主目录中的一个文件夹中。 您可以使用以下脚本执行此操作:
extractgst.sh
#!/bin/sh gst=/usr/share/gnome-shell/gnome-shell-theme.gresource workdir=${HOME}/shell-theme for r in `gresource list $gst`; do r=${r#\/org\/gnome\/shell/} if [ ! -d $workdir/${r%/*} ]; then mkdir -p $workdir/${r%/*} fi done for r in `gresource list $gst`; do gresource extract $gst $r >$workdir/${r#\/org\/gnome\/shell/} done
主题文件应当已提取到创建的目录中。现在将您想要的背景图像复制到此目录。
接下来,您需要在目录中创建一个文件,内容如下:
gnome-shell-theme.gresource.xml
<?xml version="1.0" encoding="UTF-8"?> <gresources> <gresource prefix="/org/gnome/shell/theme"> <file alias="icons/scalable/actions/color-pick.svg">color-pick.svg</file> <file alias="icons/scalable/actions/pointer-double-click-symbolic.svg">pointer-double-click-symbolic.svg</file> <file alias="icons/scalable/actions/pointer-drag-symbolic.svg">pointer-drag-symbolic.svg</file> <file alias="icons/scalable/actions/pointer-primary-click-symbolic.svg">pointer-primary-click-symbolic.svg</file> <file alias="icons/scalable/actions/pointer-secondary-click-symbolic.svg">pointer-secondary-click-symbolic.svg</file> <file alias="icons/scalable/actions/preview-close-symbolic.svg">window-close-24-symbolic.svg</file> <file alias="icons/scalable/status/carousel-arrow-next-24-symbolic.svg">carousel-arrow-next-24-symbolic.svg</file> <file alias="icons/scalable/status/carousel-arrow-back-24-symbolic.svg">carousel-arrow-back-24-symbolic.svg</file> <file alias="icons/scalable/status/eye-open-negative-filled-symbolic.svg">eye-open-negative-filled-symbolic.svg</file> <file alias="icons/scalable/status/eye-not-looking-symbolic.svg">eye-not-looking-symbolic.svg</file> <file alias="icons/scalable/status/keyboard-caps-lock-filled-symbolic.svg">keyboard-caps-lock-filled-symbolic.svg</file> <file alias="icons/scalable/status/keyboard-enter-symbolic.svg">keyboard-enter-symbolic.svg</file> <file alias="icons/scalable/status/keyboard-hide-symbolic.svg">keyboard-hide-symbolic.svg</file> <file alias="icons/scalable/status/keyboard-layout-filled-symbolic.svg">keyboard-layout-filled-symbolic.svg</file> <file alias="icons/scalable/status/keyboard-shift-filled-symbolic.svg">keyboard-shift-filled-symbolic.svg</file> <file alias="icons/scalable/status/message-indicator-symbolic.svg">message-indicator-symbolic.svg</file> <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>filename</file> <file>gnome-shell.css</file> <file>gnome-shell-high-contrast.css</file> <file>gnome-shell-start.svg</file> <file>no-events.svg</file> <file>no-notifications.svg</file> <file>pad-osd.css</file> <file>process-working.svg</file> <file>toggle-off.svg</file> <file>toggle-off-dark.svg</file> <file>toggle-off-hc.svg</file> <file>toggle-on.svg</file> <file>toggle-on-dark.svg</file> <file>toggle-on-hc.svg</file> <file>workspace-placeholder.svg</file> </gresource> </gresources>
将 filename 替换为背景图像的文件名,或移除此行后用16位色彩值替代。
现在,打开 gnome-shell.css
文件并更改 #lockDialogGroup
定义如下:
#lockDialogGroup { background: #2e3436 url(filename); background-size: [WIDTH]px [HEIGHT]px; background-repeat: no-repeat; }
将 background-size
设置为GDM使用的分辨率, 这可能不一定是图像的分辨率。显示分辨率列表见Display resolution。同样,将 filename 替换为背景图像的文件名。
If you only want to change the background color, adjust the #lockDialogGroup
definition as follows:
#lockDialogGroup { background-color: #color; }
where color is the new hex-encoded background color.
最后,使用以下命令编译主题:
$ glib-compile-resources gnome-shell-theme.gresource.xml
然后将生成的 gnome-shell-theme.gresource
文件复制到 /usr/share/gnome-shell
目录下。
然后重启 gdm.service
(注意:重启而不是退出) ,它就会使用您想要的背景图片了。
更多信息见此贴。A shell script to automate the above steps is available on DimaZirix's github repository.
dconf配置
一些 GDM 设置存储在 DConf database中。 可以通过将 keyfiles 添加到 /etc/dconf/db/gdm.d
目录,然后以root身份运行 dconf update
重新编译GDM数据库来配置它们,或者通过登陆系统上的GDM用户并使用"gsettings" 命令直接更改设置。 需要一个 GDM 配置文件 - 这必须手动创建,因为它不再向上游发送,见下文:
/etc/dconf/profile/gdm
user-db:user system-db:gdm file-db:/usr/share/gdm/greeter-dconf-defaults
For the latter approach, you can log into the GDM user with the command below:
# machinectl shell gdm@ /bin/bash
登录页面的logo
创建以下密钥文件:
/etc/dconf/db/gdm.d/02-logo
[org/gnome/login-screen] logo='/path/to/logo.png'
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch gsettings set org.gnome.login-screen logo '/path/to/logo.png'
更改光标主题
GDM会忽略GNOME光标主题设置,也忽略根据XDG specification设置的光标主题。若要更改GDM使用的光标,请创建以下密钥文件:
/etc/dconf/db/gdm.d/10-cursor-settings
[org/gnome/desktop/interface] cursor-theme='theme-name'
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch gsettings set org.gnome.desktop.interface cursor-theme 'theme-name'
在登录页面显示大字体
单击屏幕右上角的辅助功能图标(一个白色圆圈,中间有一个人的轮廓),然后选中 大号文本 选项。
要设置特定的缩放比例,可以创建以下密钥文件(以1.25为例):
/etc/dconf/db/gdm.d/03-scaling
[org/gnome/desktop/interface] text-scaling-factor='1.25'
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch gsettings set org.gnome.desktop.interface text-scaling-factor '1.25'
关闭声音
此调整禁用在登录屏幕上(通过键盘)调整系统音量时听到的声音反馈。
创建以下密钥文件:
/etc/dconf/db/gdm.d/04-sound
[org/gnome/desktop/sound] event-sounds=false
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch gsettings set org.gnome.desktop.sound event-sounds 'false'
更改电源按钮行为
- The logind settings for the power button are overriden by GNOME Settings Daemon. [1]
- As of GDM 3.18, the power button cannot be set to interactive. [2]
- In some cases, this setting will be ignored and hardcoded defaults will be used. [3]
Create the following keyfile:
/etc/dconf/db/gdm.d/05-power
[org/gnome/settings-daemon/plugins/power] power-button-action='action'
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch 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设置开启它。
若要启用轻触以点击,创建以下key文件:
/etc/dconf/db/gdm.d/06-tap-to-click
[org/gnome/desktop/peripherals/touchpad] tap-to-click=true
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click 'true'
开启或关闭无障碍菜单
若要禁用或启用无障碍菜单,创建以下key文件:
/etc/dconf/db/gdm.d/07-accessibility
[org/gnome/desktop/interface] toolkit-accessibility='boolean'
然后重新编译GDM database,或登录GDM用户并执行以下操作:
$ sudo -u gdm dbus-launch gsettings set org.gnome.desktop.interface toolkit-accessibility 'boolean'
当key的值为false
时,无障碍菜单默认关闭;true
则开启。
Enable Night Light on GDM
To enable Night Light on GDM, run
$ sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.color night-light-enabled true
键盘布局
GDM会应用系统键盘布局。见Keyboard configuration in Xorg#Using X configuration files。
When using Wayland, you may need to specify the X keyboard layout manually with localectl:
$ localectl set-x11-keymap fr
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 [4].
GDM 2.x(传统GDM)的用户需要将~/.dmrc
更改为以下内容:
~/.dmrc
[Desktop] Language=de_DE.UTF-8 # change to your default lang Layout=de nodeadkeys # change to your keyboard layout
更改语言
The system language will be applied to GDM. If a system has multiple users, it is possible to set a language for GDM different to the system language. In this case, firstly ensure that gnome-control-center is installed. Then, start gnome-control-center and choose Region & Language. In the header bar, check the Login Screen toggle button. Finally, click on Language and choose your language from the list. You will be prompted for your root password. Note that the Login Screen button will not be visible in the header bar unless multiple users are present on the system [5].
用户与登录
自动登录
将以下内容添加至/etc/gdm/custom.conf
以开启自动登陆(将username替换为您的用户名):
/etc/gdm/custom.conf
# Enable automatic login for user [daemon] AutomaticLogin=username AutomaticLoginEnable=True
or for an automatic login with a delay:
/etc/gdm/custom.conf
[daemon] TimedLoginEnable=true TimedLogin=username TimedLoginDelay=1
You can set the session used for automatic login (replace gnome-xorg
with desired session):
/var/lib/AccountsService/users/username
XSession=gnome-xorg
免密登录
If you want to bypass the password prompt in GDM then simply add the following line on the first line of /etc/pam.d/gdm-password
:
auth sufficient pam_succeed_if.so user ingroup nopasswdlogin
Then, add the group nopasswdlogin
to your system. See User group for group descriptions and group management commands.
Now, add your user to the nopasswdlogin
group and you will only have to click on your username to login.
- 不要对root账户这么做。
- You will not 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
nopasswdlogin
group.
Passwordless shutdown for multiple sessions
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
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE policyconfig PUBLIC "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN" "http://www.freedesktop.org/software/polkit/policyconfig-1.dtd"> <!-- Policy definitions for logind --> <policyconfig> <action id="org.freedesktop.login1.power-off-multiple-sessions"> <description>Shutdown the system when multiple users are logged in</description> <message>System policy prevents shutting down the system when other users are logged in</message> <defaults> <allow_inactive>yes</allow_inactive> <allow_active>yes</allow_active> </defaults> </action> </policyconfig>
You can find all available logind options (e.g. reboot-multiple-sessions) in org.freedesktop.login1(5).
在GDM中开启root登录
It is not advised to login as root, but if necessary you can edit /etc/pam.d/gdm-password
and add the following line before the line auth required pam_deny.so
:
/etc/pam.d/gdm-password
auth sufficient pam_succeed_if.so uid eq 0 quiet
The file should look something like this:
/etc/pam.d/gdm-password
... auth sufficient pam_succeed_if.so uid eq 0 quiet auth sufficient pam_succeed_if.so uid >= 1000 quiet auth required pam_deny.so ...
You should be able to login as root after restarting GDM.
在登录列表中隐藏用户
The users for the gdm user list are gathered by AccountsService. It will automatically hide system users (UID < 1000). To hide ordinary users from the login list create or edit a file named after the user to hide in /var/lib/AccountsService/users/
to contain at least:
/var/lib/AccountsService/users/username
[User] SystemAccount=true
设置默认显示器
一些桌面环境将显示设置保存在 ~/.config/monitors.xml
。xrandr 命令基于该文件内容生成信息。在GDM中类似内容保存在/var/lib/gdm/.config/monitors.xml
。
若有显示器设置(例如朝向,缩放,主屏幕等等)信息记录于~/.config/monitors.xml
中,并且想要让这些设置用于GDM:
# cp ~/.config/monitors.xml /var/lib/gdm/.config/ # chown gdm:gdm /var/lib/gdm/.config/monitors.xml
monitors.xml
文件中屏幕旋转和缩放的部分内容如下:
<monitors version="2"> <configuration> <logicalmonitor> ... <scale>2</scale> ... <transform> <rotation>right</rotation> <flipped>no</flipped> </transform> ... </logicalmonitor> </configuration> </monitors>
必须登出才能使更改生效,因为GDM不遵守xorg.conf
。
- 如果在Wayland下使用GDM,则必须使用在Wayland下创建的
monitors.xml
。详见GDM bug 224。也可以强制让GDM #使用Xorg作为后端,并使用在Xorg下创建的monitors.xml
。
gdm
.}}
配置X服务器的访问权限
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
疑难解答
Wayland与NVIDIA专有驱动
To use Wayland in GDM with the NVIDIA driver, you must first enable NVIDIA#DRM kernel mode setting.
As of GDM 42 and NVIDIA driver 510, GDM defaults to Wayland. For older NVIDIA drivers (in between version 470 and 510), GDM has chipset-dependent udev rules to use Xorg rather than Wayland. To force-enable Wayland, override these rules by creating the following symlink:
# ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
/etc/udev/rules.d/
override those in /usr/lib/udev/rules.d/
(see udev#About udev rules). It is also advised to modify files in /etc/
rather than in /usr/
as those are managed by pacman.If, instead of GDM, a black screen appears, try disabling integrated graphics in your computer's BIOS settings.
注销失败
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
Rootless Xorg
使用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:
- GDM crashes
To use the Xorg backend by default, uncomment the following line in /etc/gdm/custom.conf
:
#WaylandEnable=false
GDM does not start until input is provided
If, after booting, the screen stays black and GDM does not start until the mouse is moved or something is typed on the keyboard, it may be due to a lack of entropy required for random number generation. To confirm, check that the following line appears inside systemd-random-seed’s log (which can be read by running journalctl --unit systemd-random-seed
with root privileges):
Kernel entropy pool is not initialized yet, waiting until it is.
To fix this, you can pass the random.trust_cpu=on
kernel parameter if your CPU supports the RDRAND instruction, or you can use haveged which also provides entropy, albeit it is of allegedly low quality. See Debian’s article on the topic for other solutions.
Incomplete removal of gdm
After removing gdm, systemd may report the following:
user 'gdm': directory '/var/lib/gdm' does not exist
To remove this warning, login as root and delete the primary user gdm
and then delete the group gdm
:
Verify that gdm
is successfully removed via pwck
and grpck
with root privileges. To round it off, you may want to double-check no unowned files for gdm remain.
GDM自动挂起(GNOME 3.28)
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.
GDM ignores Wayland and uses X.Org by default
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]: [email protected]: 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]: [email protected]: Skipped due to 'exec-condition'. systemd[1022]: [email protected]: Control process exited, code=exited, status=2/INVALIDARGUMENT
See #Wayland and the proprietary NVIDIA driver for a workaround.
Black screen on AMD or Intel GPUs when an NVidia (e)GPU is present
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 (accessed by running journalctl -u gdm -b
as root):
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.
GDM cannot be enabled
See systemd/FAQ#Failure to enable unit due to preexisting symlink.