GDM (简体中文)

From ArchWiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Tango-preferences-desktop-locale.png本文或本节需要翻译。要贡献翻译,请访问简体中文翻译团队Tango-preferences-desktop-locale.png

附注: 文章大部分内容未被翻译。(在 Talk:GDM (简体中文)# 中讨论)
翻译状态:本文是 GDM翻译。上次翻译日期:2018-08-08。如果英文版本有所更改,则您可以帮助同步翻译。

来自GDM - GNOME显示管理器:“GNOME显示管理器(GDM)是一个管理图形显示服务和处理图形用户登录的程序。

显示管理器s provide X Window System and Wayland users with a graphical login prompt.

安装

可通过安装gdm包来安装GDM,或作为gnome组的一部分安装。

如果你更希望使用在GNOME 2中使用的旧的GDM和它的实用配置程序,安装gdm-oldAUR软件包。请注意,除非另有说明,否则本条目的其余部分均为讨论当前的GDM,而非旧的GDM。

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

  • gdm3setup — 一个用来配置GDM3的接口,有自动登陆选项并且能更改Shell的主题
https://github.com/Nano77/gdm3setup || gdm3setup-utilsAUR

开始

可通过enablegdm.service来在开机时启动GDM。

自动启动软件

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.

注意: /etc/gdm/Init目录不再是受支持的位置,参见[1].

配置

登录页面背景图片

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

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 (简体中文))
注意:
  • 自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>calendar-arrow-left.svg</file>
    <file>calendar-arrow-right.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>close.svg</file>
    <file>close-window-active.svg</file>
    <file>close-window-hover.svg</file>
    <file>close-window.svg</file>    		
    <file>corner-ripple-ltr.png</file>
    <file>corner-ripple-rtl.png</file>
    <file>dash-placeholder.svg</file>
    <file>filter-selected-ltr.svg</file>
    <file>filter-selected-rtl.svg</file>
    <file>gnome-shell.css</file>	
    <file>gnome-shell-high-contrast.css</file>
    <file>icons/message-indicator-symbolic.svg</file>
    <file>key-enter.svg</file>
    <file>key-hide.svg</file>
    <file>key-layout.svg</file>
    <file>key-shift-latched-uppercase.svg</file>
    <file>key-shift.svg</file>
    <file>key-shift-uppercase.svg</file>
    <file>logged-in-indicator.svg</file>
    <file>no-events.svg</file>
    <file>no-notifications.svg</file>
    <file>filename</file>
    <file>pad-osd.css</file>
    <file>page-indicator-active.svg</file>		
    <file>page-indicator-checked.svg</file>
    <file>page-indicator-hover.svg</file>
    <file>page-indicator-inactive.svg</file>
    <file>process-working.svg</file>
    <file>running-indicator.svg</file>
    <file>source-button-border.svg</file>
    <file>summary-counter.svg</file>
    <file>toggle-off-hc.svg</file>
    <file>toggle-off-intl.svg</file>
    <file>toggle-off-us.svg</file>		
    <file>toggle-on-hc.svg</file>		
    <file>toggle-on-intl.svg</file>
    <file>toggle-on-us.svg</file>		
    <file>ws-switch-arrow-down.png</file>
    <file>ws-switch-arrow-up.png</file>
  </gresource>
</gresources>

filename 替换为背景图像的文件名。

现在,打开 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 替换为背景图像的文件名。

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

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

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

然后重启 gdm.service (注意:仅仅退出是不够的) 然后你会发现它在使用你喜欢的背景图片。

有关更多信息,请参阅以下内容 forum thread.

DConf configuration

一些 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@

创建以下密钥文件

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

然后重新编译 GDM database或登录 GDM 用户并执行以下操作:

$ 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 用户并执行以下操作:

$ gsettings set org.gnome.desktop.interface cursor-theme 'theme-name'

在登录页面显示大字体

单击屏幕右上角的辅助功能图标(一个白色圆圈,中间有一个人的轮廓),然后选中 Large Text 选项。

要设置特定的缩放因子,您可以创建以下密钥文件:

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

然后重新编译 GDM database或登录 GDM 用户并执行以下操作:

$ 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 用户并执行以下操作:

$ gsettings set org.gnome.desktop.sound event-sounds 'false'

更改电源按钮行为

注意:
  • The logind settings for the power button are overriden by GNOME Settings Daemon. [2]
  • As of GDM 3.18, the power button cannot be set to interactive. [3]
  • In some cases, this setting will be ignored and hardcoded defaults will be used. [4]
警告: Please note that the acpid daemon also handles the "power button" and "hibernate button" events. Running both systems at the same time may lead to unexpected behaviour.

Either create the following keyfile:

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

and then recompile the GDM database or alternatively log in to the GDM user and execute the following:

$ 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设置轻松地开启它。

注意: 如果你想要在X下这么做,you have to first set up correct X server access permissions - see #Configure X server access permission.

可用以下命令直接开启轻触以点击:

# sudo -u gdm gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true

如果你想使用GUI,请使用:

# sudo -u gdm dconf-editor

检查它是否被正确开启:

$ sudo -u gdm gsettings get org.gnome.desktop.peripherals.touchpad tap-to-click

如果你得到一个错误:dconf-WARNING **: failed to commit changes to dconf: Error spawning command line,请确认dbus正在运行:

$ sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click true

开启或关闭无障碍菜单

在dconf编辑器中设置以下key以关闭或开启无障碍菜单。

# machinectl shell gdm@
# gsettings set org.gnome.desktop.interface toolkit-accessibility false
# exit

当key是false时,无障碍菜单被默认关闭;true时为开启。

键盘布局

系统键盘布局会被应用到GDM。参见Keyboard configuration in Xorg#Using X configuration files

提示: 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].

GDM 2.x(legacy 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 [6].

提示: By adding 2 different input languages, logging out then selecting your default language GDM will remember your choice once the second option is removed.

用户与登录

自动登录

将以下内容添加至/etc/gdm/custom.conf以开启自动登陆(将username替换为你的用户名):

/etc/gdm/custom.conf
# Enable automatic login for user
[daemon]
AutomaticLogin=username
AutomaticLoginEnable=True
提示: If GDM fails after adding these lines, comment them out from a TTY.

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/standards/PolicyKit/1.0/policyconfig.dtd">


<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) here.

在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

设置默认显示器

一些 Desktop environment (简体中文) 保存显示设置于 ~/.config/monitors.xmlxrandr 命令基于该文件内容生成信息。在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

Configure X server access permission

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

已知问题

无法使用NVIDIA(英伟达)闭源驱动

GDM uses the Wayland backend by default which conflicts with NVIDIA driver. Turning off the Wayland backend could enable proprietary NVIDIA driver.

注销失败

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#Rootless Xorg

使用Xorg作为后端

The Wayland backend is used by default and the Xorg backend is used only if the Wayland backend cannot be started. As the Wayland backend has been reported to cause problems for some users, use of the Xorg backend may be necessary. To use the Xorg backend by default, edit the /etc/gdm/custom.conf file and uncomment the following line:

#WaylandEnable=false

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

# 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自动挂起(GNOME 3.28)

GDM uses a separate dconf database to control power management. You can make GDM behave the same way as user sessions by copying the user settings to GDM's dconf database.

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

Or to simply disable auto-suspend (also run the command with ac replaced with battery to also disable it while running on battery):

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

参见