LightDM
- 跨桌面 - 支持不同的桌面环境.
- 支持多种显示技术(X,Mir,Wayland, ...).
- 轻量级 - 低内存使用,高性能.
- 支持访客会话.
- 支持远程登录(请求 - XDMCP, VNC, 输出 - XDMCP, PAM).
- 完善的测试组件.
- 低代码复杂度.
更多关于LightDM的特点可以在这里找到。
安装[编辑 | 编辑源代码]
Greeter[编辑 | 编辑源代码]
使用 LightDM 可能需要安装一个 greeter。 greeter 是提示用户输入凭据、让用户选择一个会话等的图形界面。在配置了自动登录的情况下,可以不使用 greeter。否则需要安装 xorg-server包 和至少一个下面的 greeter。
官方软件仓库包含如下 greeter:
- lightdm-gtk-greeter包: 被 LightDM 默认使用的 greeter, 除非用户手动设置使用其他 greeter。
- lightdm-deepin-greeter (deepin-session-shell包): 由 深度 桌面提供。
- lightdm-pantheon-greeter包: 来自 ElementaryOS 项目的 greeter。
- lightdm-slick-greeter包: 比 lightdm-gtk-greeter包 更注重美化的 GTK greeter , 从 lightdm-unity-greeterAUR 分支发展而来, 被 Linux Mint 发行版默认使用。
- lightdm-webkit2-greeter包: 一个用 Webkit2 做主题引擎的 greeter, 取代了 lightdm-webkit-greeterAUR。
- lightdm-webkit-theme-litarvan包: 现代且功能齐全的 Webkit2 LightDM 主题。
其他的 greeter 可以从 AUR 安装:
- lightdm-unity-greeterAUR: Ubuntu Unity 使用的 greeter。
- lightdm-mini-greeterAUR: 一个最小化可配置的单用户 greeter。
- lightdm-webkit-theme-aetherAUR: 在 lightdm 和 lightdm-webkit2-greeter 上编写的时尚、直接的 Arch Linux 主题登录屏幕。
- lightdm-elephant-greeter-gitAUR: 默认情况下在 cage包 Wayland 合成器中运行的小而简单的欢迎程序。
- web-greeterAUR: 一个高颜值的现代化 greeter,使用 PyQtWebEngine 作为主题,替代 lightdm-webkit2-greeter包。
可以通过配置文件的 [Seat:*]
设置修改 greeter:
/etc/lightdm/lightdm.conf
[Seat:*] ... greeter-session=lightdm-你要用的greeter名-greeter
io.elementary.greeter.conf
, 而不是 lightdm-pantheon-greeter.conf
检查有哪些 greeter-session
可用的一种办法是列出 /usr/share/xgreeters
目录中的文件; 每个“.desktop”文件代表一个可用的欢迎程序。 在这个例子中,lightdm-gtk-greeter
和 lightdm-webkit2-greeter
greeter 可用:
$ ls -1 /usr/share/xgreeters/ lightdm-gtk-greeter.desktop lightdm-webkit2-greeter.desktop
启用 LightDM[编辑 | 编辑源代码]
确保使用 systemctl 启用 lightdm.service
,如此来让 LightDM 开机启动。参考 显示管理器#加载显示管理器。
命令行工具[编辑 | 编辑源代码]
LightDM 提供一个命令行工具, dm-tool
。它可用来锁定当前 Seat,切换会话,等等。这对'极简'窗口管理器和测试非常有用。要列出可用命令,可以运行:
$ dm-tool --help
用户切换[编辑 | 编辑源代码]
dm-tool lock
或 dm-tool switch-to-greeter
不会锁定会话, 请参阅 XScreenSaver#从锁屏画面切换登录用户。LightDM 的 dm-tool 命令能用于允许多个用户在单独的终端上登录。运行下面的命令会发送一个请求锁定当前会话的信号,然后将启动切换到 LightDM 的欢迎程序,以允许新用户登录系统。
$ dm-tool switch-to-greeter
测试[编辑 | 编辑源代码]
首先,安装 xorg-server-xephyr包.
之后,把 LightDM 作为 X 程序启动:
$ lightdm --test-mode --debug
配置和调整[编辑 | 编辑源代码]
可以通过修改其配置文件 /etc/lightdm/lightdm.conf
来配置LightDM,某些 greeter 拥有自己的配置文件。例如
- lightdm-gtk-greeter包:
/etc/lightdm/lightdm-gtk-greeter.conf
(或者你也可以使用 lightdm-gtk-greeter-settings包 图形化配置程序), - lightdm-webkit2-greeter包:
/etc/lightdm/lightdm-webkit2-greeter.conf
可以直接修改 LightDM 的配置文件,或者使用位于 /usr/lib/lightdm/lightdm/
的 lightdm-set-defaults
程序。想知道一些可用选项,执行:
$ man lightdm-set-defaults
然而一大部分变量要直接编辑配置文件而不是使用 lightdm-set-defaults
程序。
X 会话包装器[编辑 | 编辑源代码]
如果是从 xinit 迁移过来,可以注意到显示服务不是由 shell 启动的。这是因为,与 shell 启动显示服务并继承 shell 的环境相反,LightDM 启动的图形界面并不读取 shell。LightDM 通过运行包装器脚本启动显示服务,最后执行您的图形环境。默认情况下,会运行 /etc/lightdm/Xsession
。
环境变量[编辑 | 编辑源代码]
该脚本会按照先后顺序检查并读取 /etc/profile
、~/.profile
、/etc/xprofile
和 ~/.xprofile
。如果实际使用的 shell 不会读取这些文件,也可以创建一个 ~/.xprofile
来达到同样的效果。 (在这个例子中,登录 shell 是 zsh)
~/.xprofile
#!/bin/sh [ -f ~/.config/zsh/.zshenv ] && . ~/.config/zsh/.zshenv
如果有对显示服务非常重要的 shell 变量(例如 Gtk 或 QT 主题、GNUPG 位置、要覆盖的配置等),这就可以让图形环境可以访问到设定的环境变量,而不必通过登录 shell 来启动。
键盘映射[编辑 | 编辑源代码]
该脚本使用文件 /etc/X11/Xkbmap
、~/.Xkbmap
中提供的参数运行 Xkbmap。如果没有找到这些文件,它将运行 xmodmap 和 /etc/X11/Xmodmap
,~/.Xmodmap
。 如果使用 xkbmap,则使用 cat 解析文件。 下面是一个可以生效的示例:
~/.Xmodmap
-model pc105 -layout us,us,tr -variant ,dvorak,f -option grp:caps_toggle
否则,会话将继承X11的系统默认映射。这个映射可以在 xorg 配置文件中定义,手动编辑或使用 localectl set-x11-keymap
命令。参见Xorg/键盘配置#设置键盘布局。
在 lightdm-gtk-greeter 中使用多个键盘布局[编辑 | 编辑源代码]
要使用户能够在登录屏幕上的预定义键盘布局之间切换,请启用下拉菜单并配置布局。使用 lightdm-gtk-greeter-settings包 gui 进行配置或直接编辑配置文件:
/etc/lightdm/lightdm-gtk-greeter.conf
[greeter] indicators = ~host;~spacer;~clock;~spacer;~layout;~language;~session;~a11y;~power
使用 localectl 来设置多个布局, 例如 de 和它的 变体 且以后者为主:
# localectl --no-convert set-x11-keymap de,de pc105 neo,
请注意末尾的逗号,这意味着第二个 de 的空白变体。
更改背景图片/颜色[编辑 | 编辑源代码]
如果您想使用一个纯色 (非图片) 的背景,只需将 background
变量设置为十六进制的颜色。
例如:
background=#000000
如果你想用图像来代替,请看下文。
GTK+ greeter[编辑 | 编辑源代码]
可以使用 lightdm-gtk-greeter-settings包 图形界面进行设置。
如果需要在 greeter 上使用自定义图片,请修改 /etc/lightdm/lightdm-gtk-greeter.conf
中的 background
变量值。变量位于 [greeter]
会话,例如:
/etc/lightdm/lightdm-gtk-greeter.conf
[greeter] background=/usr/share/pixmaps/black_and_white_photography-wallpaper-1920x1080.jpg
/usr/share/pixmaps
,因为 LightDM 用户需要有背景文件的读取权限。可以通过 [greeter]
段落的 theme-name
变量配置 GTK3 主题、图标主题以及指针主题:
/etc/lightdm/lightdm-gtk-greeter.conf
[greeter] theme-name = Tela icon-theme-name = Tela cursor-theme-name = Tela cursor-theme-size = 32 font-name = Cantarell 20
Webkit2 greeter[编辑 | 编辑源代码]
The lightdm-webkit2-greeter包 allows you to choose a background image directly on the login screen. It also offers an option to display a random image each time it starts if you use the Material theme. By default, images are sourced from /usr/share/backgrounds
. You can change the background images directory by editing lightdm-webkit2-greeter.conf
. For example:
/etc/lightdm/lightdm-webkit2-greeter.conf
[branding] background_images = /usr/share/backgrounds
Unity greeter[编辑 | 编辑源代码]
如果使用的是 lightdm-unity-greeterAUR,请修改 /usr/share/glib-2.0/schemas/com.canonical.unity-greeter.gschema.xml
,然后执行:
# glib-compile-schemas /usr/share/glib-2.0/schemas/
可以参考这个页面。
Slick Greeter[编辑 | 编辑源代码]
使用 lightdm-settingsAUR 图形界面设置。
更改头像[编辑 | 编辑源代码]
首先确保已安装 accountsservice包 软件包,然后如下设置,把 username
替换为目标用户的登录名。文件名中不要加 .png 后缀。
- 编辑或创建
/var/lib/AccountsService/users/username
, 添加如下内容:
[User] Icon=/var/lib/AccountsService/icons/username.png
I
- 使用 96x96 PNG 图表文件来创建
/var/lib/AccountsService/icons/username.png
.
Arch 为中心的 64x64 图标来源[编辑 | 编辑源代码]
archlinux-artworkAUR 软件包包含了一些不错的例子。它们被安装到 /usr/share/archlinux/icons
, 可如下复制到 /usr/share/icons/hicolor/64x64/devices
:
# find /usr/share/archlinux/icons -name "*64*" -exec cp {} /usr/share/icons/hicolor/64x64/devices \;
复制之后,可删除 archlinux-artworkAUR.
启用自动登录[编辑 | 编辑源代码]
编辑 LightDM 配置文件,取消该行的注释,并添加要自动登陆的用户名:
/etc/lightdm/lightdm.conf
autologin-user=username
要让用户登录时不用输入密码,用户必须是 autologin
组的成员:
# groupadd autologin # gpasswd -a username autologin
LightDM logs in using the session specified in the ~/.dmrc
of the user getting logged in automatically. To override this file, specify autologin-session
in lightdm.conf
:
/etc/lightdm/lightdm.conf
[Seat:*] autologin-user=username autologin-session=session
The list of valid session names can be found by listing /usr/share/xsessions/*.desktop
for X's sessions and /usr/share/wayland-sessions/*.desktop
for Wayland's.
启用无密码交互登录[编辑 | 编辑源代码]
LightDM 使用 PAM 完成登录操作,因此你必须在此之前配置好与LightDM相关的PAM配置
/etc/pam.d/lightdm
#%PAM-1.0 auth sufficient pam_succeed_if.so user ingroup nopasswdlogin auth include system-login ...
同时你必须是 nopasswdlogin
组的成员以完成无密码登录的过程
# groupadd -r nopasswdlogin # gpasswd -a username nopasswdlogin
To create a new user account that logs in automatically and additionally able to login again without a password the user can be created with supplementary membership of both groups, e.g.:
# useradd -mG autologin,nopasswdlogin -s /bin/bash username
Enabling guest sessions[编辑 | 编辑源代码]
To enable guest sessions in LightDM (without changing your system configuration) you need at least two things:
- a guest-account-script: defaults to
guest-account
and accepts two commands:- add (to create a temporary guest system account and returns the user name of the created account)
- remove account name(to delete the corresponding account)
- an autologin group to which the created guest account must be added (cf.
/etc/pam.d/lightdm-autologin
)
There are two AUR packages that enable guest sessions in lightdm:
- lightdm-guestAUR which provides the (largely unmodified) upstream guest-session script as well as lightdm包 itself.
- lightdm-guest-accountAUR which provides only a minimal version of the script.
隐藏系统和服务用户[编辑 | 编辑源代码]
为防止系统用户出现在登录界面,安装可选依赖 accountsservice包, 或者把这些用户名添加到 /etc/lightdm/users.conf
下的 hidden-users
里。前者优势在于添加/删除用户时不用更新列表。
从 SLiM 迁移[编辑 | 编辑源代码]
把 xinitrc 的内容搬到 xprofile, 删除调用窗口管理器或桌面环境的部分。
使用 ~/.xinitrc 登录[编辑 | 编辑源代码]
请参考 Display manager#Run ~/.xinitrc as a session。
默认打开小键盘[编辑 | 编辑源代码]
安装 numlockx包, 编辑 /etc/lightdm/lightdm.conf
添加以下几行:
/etc/lightdm/lightdm.conf
[Seat:*] greeter-setup-script=/usr/bin/numlockx on
Xfce4 下多用户切换[编辑 | 编辑源代码]
如果您使用 Xfce 桌面,在应用程序启动器/Whisker Menu 的活动按钮的多用户切换功能会特别关注 gdmflexiserver 可执行程序以启用自身。如果你提供了一个可执行 Shell 脚本 /usr/bin/gdmflexiserver
并且它包含
#!/bin/sh /usr/bin/dm-tool switch-to-greeter
如此 Xfce 下多用户切换应该在 Lightdm 有效。
Alternatively, if you use the Whisker Menu, you can go to Properties -> Commands and change the "Switch Users" command directly to:
dm-tool switch-to-greeter
你也可从 XScreenSaver 锁屏界面切换用户 - 参见 XScreenSaver#LightDM.
默认会话[编辑 | 编辑源代码]
Lightdm, 像其他 DM 一样,把上次选择的 xsession 存储在 ~/.dmrc
. 更多信息见 Display manager#Session configuration.
修改登录窗口的位置[编辑 | 编辑源代码]
GTK+ greeter[编辑 | 编辑源代码]
编辑 /etc/lightdm/lightdm-gtk-greeter.conf
文件,设置 position
,这个设置接受 x
和 y
变量,可以使用绝对值(pixels)或相对值(percent). 每个变量都可以增加一个额外的锚定位置 start
, center
和 end
,数值间用 comma 分隔.
Example:
position=200,start 50%,center
VNC Server[编辑 | 编辑源代码]
Lightdm can also be used to connect to via VNC. Make sure to install tigervnc包 on the server side and optionally as your VNC client on the client PC.
Setup an authentication password on the server as root:
# vncpasswd /etc/vncpasswd
Edit the LightDM configuration file as shown below. Note that listen-address
configures the VNC to only listen to connections from localhost. This is used to only allow connections via SSH and port forwarding. On the SSH client, make sure that you use localhost:5900
for the tunnel destination; using 127.0.0.1:5900
or ::1:5900
is not reliable on dual stack network connections. If you want to allow insecure connections you can disable this setting.
/etc/lightdm/lightdm.conf
[VNCServer] enabled=true command=Xvnc -rfbauth /etc/vncpasswd port=5900 listen-address=localhost width=1024 height=768 depth=24
Now open an SSH tunnel and connect to localhost as described in TigerVNC#On the client.
Lock the screen using light-locker[编辑 | 编辑源代码]
light-locker包 is a simple screen locker using LightDM to authenticate the user. Once installed and running, you can lock your session via:
$ light-locker-command -l
This requires light-locker
to be started at the beginning of your session. By default, this is enabled through XDG Autostart. See Autostarting for more options.
Multiple-monitor setup[编辑 | 编辑源代码]
Sometimes LightDM does not set the monitor resolution correctly on a multiple-monitor setup. The following Xorg configuration works with two monitors: a large primary screen on the left side, and a secondary smaller screen to its right. The order can be reversed and tweaked.
/etc/X11/xorg.conf.d/52-resolution-fix.conf
Section "Monitor" Identifier "DP1" Option "PreferredMode" "3840x2160" Option "Primary" "1" EndSection Section "Monitor" Identifier "eDP1" Option "PreferredMode" "1920x1080" Option "RightOf" "DP1" EndSection
This makes the display-setup-script
tweaks from /etc/lightdm/lightdm.conf
redundant.
疑难问题[编辑 | 编辑源代码]
Autologin does not work[编辑 | 编辑源代码]
Ensure autologin-user=
in /etc/lightdm/lightdm.conf
contain the correct values. Trailing whitespace will cause errors.
If autologin fails with a blank screen or if the login screen immediately returns, you may need to set logind-check-graphical=true
.
You can also install lightdm-autologin-greeter-gitAUR for this special purpose.
Viewing current configuration[编辑 | 编辑源代码]
To view effective configuration, run:
$ lightdm --show-config
This will show current settings, with the configuration files these settings were read from.
LightDM not starting and screen flashing[编辑 | 编辑源代码]
如果你一直屏幕闪烁并且启动后没有 lightdm, 确保你已在 lightdm 的配置文件里正确设置了 greeter. 如果你正确设置了 GTK greeter, 确保 xsessions-directory
(默认是: /usr/share/xsessions
) 存在并且至少包含一个 .desktop 文件。
如果你上次选择的会话永久失效了,lightdm 启动时也可能有同样问题 (例如上次使用的是 gnome 并删除了 gnome-session 软件包): 最简单的解决方法就是恢复删掉的软件包。另一个可能的解决是:
# dbus-send --system --type=method_call --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts/User1000 org.freedesktop.Accounts.User.SetXSession string:xfce
此例为用户 1000 设置默认会话为 "xfce".
显示错误语言环境[编辑 | 编辑源代码]
如果 Lightdm 未正常显示你的语言环境,把你的语言环境添加到 /etc/environment
(自己酌情更改)
LANG=pt_PT.utf8
Alternatively if you want LightDM and its greeters to be in a language other than your set system locale, you can use the Environment=
option in Systemd#Drop-in files.
Unresponsive for a few minutes after startup[编辑 | 编辑源代码]
You may have to download more entropy. Install and enable haveged, c.f. https://github.com/canonical/lightdm/issues/17
使用 GTK greeter 丢失图标[编辑 | 编辑源代码]
如果你把 lightdm-gtk-greeter包 作为 greeter 并且它把占位符图像显示为图标,确保已安装和正确配置有效的图标主题和主题。检查如下文件:
/etc/lightdm/lightdm-gtk-greeter.conf
[greeter] theme-name=mate # this should be the name of a directory under /usr/share/themes/ icon-theme-name=mate # this should be the name of a fully featured icons set directory under /usr/share/icons/
LightDM 在登录提示符处冻结[编辑 | 编辑源代码]
你会发现当输入正确的用户名和密码尝试登录时 LightDM 冻结,你无法进入桌面。为修复,重新安装 gdk-pixbuf2包 软件包。参见 这个论坛帖子。
LigthDM 显示在错误的显示器上[编辑 | 编辑源代码]
如果你使用的多显示器,LightDM 可能会显示在不该出现的那一个上 (例如: 主显示器在左边). 为强制 LightDM 登录界面显示在特定的显示器上,编辑 /etc/lightdm/lightdm.conf
更改 display-setup-script 参数如下:
/etc/lightdm/lightdm.conf
display-setup-script=xrandr --output HDMI-1 --primary
替换 HDMI-1 为你的正确的显示器 ID, 可从 xrandr 命令输出获取。
Alternatively, if you are using the GTK greeter, you can edit /etc/lightdm/lightdm-gtk-greeter.conf
and add the active-monitor parameter like this:
/etc/lightdm/lightdm-gtk-greeter.conf
[greeter] active-monitor=0
Replace 0 with the desired display number.
LightDM does not appear or monitor only displays TTY output[编辑 | 编辑源代码]
可能系统启动太快了,LightDM 服务在图形驱动加载前就启动了。如果是这样,将下面配置加入 lightdm.conf 文件:
/etc/lightdm/lightdm.conf
[LightDM] logind-check-graphical=true
设置后 LightDM 会等待图形驱动加载完成后再启动 greeters/autostarting 会话。
With newer versions of LightDM, this is now the default setting. As a consequence, on some hardware, your graphics drivers may not be properly detected and LightDM may never attempt to launch a greeter--even after the system has stabilized after boot. If this occurs, setting this to false will disable the check and force LightDM to launch a greeter regardless.
LightDM is running with low FPS on Intel Graphics[编辑 | 编辑源代码]
See Intel graphics#AccelMethod.
Pulseaudio 不自动启动[编辑 | 编辑源代码]
Long pause before LightDM shows up when home is encrypted[编辑 | 编辑源代码]
Some LightDM themes try to access the user avatar located in HOME. If your HOME is encrypted, LightDM cannot access it and hangs. To prevent this from happening, you can either:
- Set your avatar as explained in #Changing your avatar
- for lightdm-gtk-greeter包 only:
hide-user-image = true
in/etc/lightdm/lightdm-gtk-greeter.conf
Boot hangs on "[ OK ] Reached target Graphical Interface."[编辑 | 编辑源代码]
There is a possibility that user and group lookups fail if you modified /etc/nsswitch.conf
. That happens when nsswitch.conf
group: includes ldap
without setting nss_initgroups_ignoreusers ALLLOCAL
in /etc/nslcd.conf
Wayland session not working with duplicate GNOME entries in greeter[编辑 | 编辑源代码]
Some greeters (lightdm-webkit2-greeter包 for example) do not support two sessions with the same name [1]. To check for duplicate entries:
$ ls -1 /usr/share/wayland-sessions /usr/share/xsessions
Rename the duplicate entry in /usr/share/xsessions
. For example:
# mv /usr/share/xsessions/gnome.desktop /usr/share/xsessions/gnome.desktop.disabled
Login always segfaults on first attempt[编辑 | 编辑源代码]
Set a hostname as described in Network Page. See also FS#47694.
Infinite login loop[编辑 | 编辑源代码]
If you get stuck in loop in which you type your correct user and password but the screen goes black and the you are back in the login after every attempt, running rm ~/.Xauthority
(or the stuck user's problematic .Xauthority
) may fix the issue.
Another reason for this may be that you tried to recreate your "lightdm.conf" from scratch and your version is missing this line:
session-wrapper=/etc/lightdm/Xsession
In that case, lightdm tries to use "lightdm-session" as the session-wrapper which does not exist on Arch Linux.