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。
您可能還希望安裝以下內容:
- loginized — Gnome GDM Login Theme Manager.
https://github.com/juhaku/loginized || loginizedAUR
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
-----------------
#!/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-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>
將文件名替換為背景圖像的文件名,或刪除該行以使用十六進制顏色值代替。
現在,打開目錄中的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(請注意,僅注銷是不夠的),您應該發現它正在使用您喜歡的背景圖像。
有關更多信息,請參見以下論壇主題。 DimaZirix的github 中提供了可自動執行上述步驟的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:
/etc/dconf/profile/gdm
----------------------------
user-db:user
system-db:gdm
file-db:/usr/share/gdm/greeter-dconf-defaults
對於后一種方法,您可以使用以下命令登錄GDM用戶:
# machinectl shell gdm@ /bin/bash
登錄屏幕logo
創建以下關鍵文件
/etc/dconf/db/gdm.d/02-logo
------------------------------
[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]
cursor-theme='theme-name'
然后重新編譯GDM數據庫,或者登錄到GDM用戶並執行以下操作:
$ gsettings set org.gnome.desktop.interface cursor-theme 'theme-name'
較大字體的登錄屏幕
單擊屏幕右上角的輔助功能圖標(白色圓圈,中間是一個人的輪廓),然后選中“大文本”選項。
要設置特定的縮放比例,可以創建以下文件:
/etc/dconf/db/gdm.d/03-scaling
----------------------------------
[org/gnome/desktop/interface]
text-scaling-factor='1.25'
然后重新編譯GDM數據庫,或者登錄到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數據庫,或者登錄到GDM用戶並執行以下操作:
$ gsettings set org.gnome.desktop.sound event-sounds 'false'
配置電源按鈕行為
Note:
- 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]
Warning: 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.
創建以下 文件:
/etc/dconf/db/gdm.d/05-power
----------------------------------
[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
.
Enabling tap-to-click
默認情況下,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/peripherals/touchpad]
tap-to-click=true
and then recompile the GDM database or alternatively log in to the GDM user and execute the following:
$ gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click 'true'
禁用/啟用輔助功能菜單
要禁用或啟用“輔助功能菜單”,請創建以下 文件:
/etc/dconf/db/gdm.d/07-accessibility
----------------------------------
[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上啟用夜間模式
要在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
-----------------------------
[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].
Tip: By adding 2 different input languages, logging out then selecting your default language GDM will remember your choice once the second option is removed.
用戶和登錄
自動登錄
要啟用GDM自動登錄,請將以下內容添加到/etc/gdm/custom.conf
中(用您自己的用戶名替換):
/etc/gdm/custom.conf
-----------------------------------
# Enable automatic login for user
[daemon]
AutomaticLogin=username
AutomaticLoginEnable=True
Tip: 如果添加這些行后GDM失敗,請從TTY中將其注釋掉。.
或延遲自動登錄:
/etc/gdm/custom.conf
-------------------------------
[daemon]
TimedLoginEnable=true
TimedLogin=username
TimedLoginDelay=1
您可以設置用於自動登錄的會話 (replace gnome-xorg
with desired session):
/var/lib/AccountsService/users/username
-------------------------------------
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:
- 不要對root帳戶執行此操作。
- 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
nopasswdlogin
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
--------------------------------------
<?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登錄
不建議以root用戶身份登錄,但如有必要,您可以進行編輯 /etc/pam.d/gdm-password
並在該行之前添加以下行 auth required pam_deny.so
:
/etc/pam.d/gdm-password
auth sufficient pam_succeed_if.so uid eq 0 quiet
文件應如下所示:
/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 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
故障排除
Wayland和專有的NVIDIA驅動程序
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
Rootless Xorg
See Xorg#Rootless Xorg.
Use Xorg backend
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可能會為您顯示黑屏,並且左上方的白色光標閃爍。 這可能是由於GDM在完全初始化圖形驅動程序之前啟動而引起的。 一種可能的解決方法是盡早啟動KMS。 另一個可能的解決方法是編輯systemd服務,並將其類型設置為“ idle”或添加一個小的延遲:
[Service]
Type=idle
or
[Service]
ExecStartPre=/bin/sleep 2
If a longer delay is required, increase the delay time.
GDM沒有啟動,直到有輸入
如果在引導后屏幕保持黑色,並且直到移動鼠標或在鍵盤上鍵入內容后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刪除不完全
刪除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自動暫停(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默認使用X.Org忽略Wayland
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"
裝有NVidia(e)GPU的AMD或Intel GPU上出現黑屏
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.