Greetd and greetd tutorial

Common display managers (or login managers) include LightDM, GDM, Ly, etc. Most of them are written in C and often only support graphical interfaces or command line interfaces. greetd is written in rust, supports wayland, and supports both command line and graphical interface (greeter).

This article introduces the use of greetd and regreet to complete the startup environment configuration in the labwc environment.

Final effect diagram:

greetd-regreet

greetd has been around for several years, first commit in 2019:

1commit 2571da3772ff3219af1ccfce169bcaab5603501f
2Author: Kenny Levinsen <kl@kl.wtf>
3Date: Tue Sep 10 00:36:35 2019 +0200
4
5     Initial commit

It should be the only one that currently supports both console and graphical greeters.

Regret is also written in rust. It was not long after it was born, and it feels pretty good after reading it.

Before experimenting with a combination of the two, I mostly used gdm3 and ly, both of which were bland and Gnome-related stuff was pretty restrictive.

Not much to say, the following is the operation process.

1. greetd manual installation

Source code After downloading, it is very easy to install like other rust applications:

 1# Compile greetd and agreement.
 2cargo build --release
 3
 4# Put things into place
 5sudo cp target/release/{greetd,agreety} /usr/local/bin/
 6sudo cp greetd.service /etc/systemd/system/greetd.service
 7mkdir /etc/greetd
 8cp config.toml /etc/greetd/config.toml
 9
10# Create the greeter user
11sudo useradd -M -G video greeter
12sudo chmod -R go+r /etc/greetd/
13
14# Look in the configuration file `/etc/greetd/config.toml` and edit as appropriate.
15# When done, enable and start greeted
16systemctl enable --now greetd

After the installation is complete, after checking, it will be automatically associated with display-manager.service, ly, gdm3, etc. have the same logic. It means that after the Linux system is started, the greet service will be run at the end, and then greet will be called by greeter.

1➜ ls -al /etc/systemd/system/display-manager.service
2lrwxrwxrwx 1 root root 34 Aug 24 15:18 /etc/systemd/system/display-manager.service -> /etc/systemd/system/greetd.service

Do not restart the system at this time, and explain the reason later.

2. Install Regreet

After downloading source code, compile it directly.

1cargo build --all-features --release

Copy out commands for system use

1sudo cp target/release/regreet /usr/bin/regreet

If you need to set other things, please check the readme document of the project. This article only introduces the core steps.

3. Configuration file

The configuration files for both greet and greet are in:

 1➜ greetd ls
 2config.toml agree.css agree.toml
 3➜ greetd pwd
 4/etc/greetd
 5➜ greetd cat config.toml
 6[terminal]
 7# The VT to run the greeter on. Can be "next", "current" or a number
 8# designating the VT.
 9vt = 1
10
11# The default session, also known as the greeter.
12[default_session]
13
14# `agreety` is the bundled agetty/login-lookalike. You can replace `/bin/sh`
15# with whatever you want started, such as `sway`.
16# command = "agreety --cmd /bin/sh"
17command = "labwc -s greet"
18
19# The user to run the command as. The privileges this user must have depends
20# on the greeter. A graphical greeter may for example require the user to be
21# in the `video` group.
22user = "greeter"
23➜ greetd cat greet.toml
24#SPDX-FileCopyrightText: 2022 Harish Rajagopal <harish.rajagopals@gmail.com>
25#
26# SPDX-License-Identifier: GPL-3.0-or-later
27
28[background]
29# Path to the background image
30# path = "/usr/share/backgrounds/greeter.jpg"
31path = "/usr/share/backgrounds/guilin.jpg"
32
33# How the background image covers the screen if the aspect ratio doesn't match
34# Available values: "Fill", "Contain", "Cover", "ScaleDown"
35# Refer to: https://docs.gtk.org/gtk4/enum.ContentFit.html
36# NOTE: This is ignored if ReGreet isn't compiled with GTK v4.8 support.
37fit = "Contain"
38
39# The entries defined in this section will be passed to the session as environment variables when it is started
40[env]
41ENV_VARIABLE = "value"
42
43[GTK]
44# Whether to use the dark theme
45application_prefer_dark_theme = true
46
47# Cursor theme name
48cursor_theme_name = "Adwaita"
49
50# Font name and size
51font_name = "Cantarell 16"
52
53# Icon theme name
54#icon_theme_name = "Adwaita"
55icon_theme_name = "Papirus"
56
57# GTK theme name
58#theme_name = "Adwaita"
59theme_name = "Orchis-Green"
60
61[commands]
62# The command used to reboot the system
63reboot = [ "systemctl", "reboot" ]
64
65# The command used to shut down the system
66poweroff = [ "systemctl", "poweroff" ]

config.toml is the configuration file of greetd, and greet.tom is the configuration file of greet. Refer to My Configuration.

The configuration items are very clear in the comments. The only thing worth explaining is command = "labwc -s regret", which I figured out. If you are not in the labwc environment (for example, you use sway), check the greetd documentation for how to set it up.

regreet.css I tested it, but it didn’t take effect, the default value is fine.

Some readers may not understand the difference between login manager and greeter.

Many login managers and greeters are bundled together, such as gdm3.

Some are separate, like lightDM, the login manager needs a greeter to work together. From the above login manager and greeter configuration files, we can still see the difference in function. The login manager is responsible for using the VT (tty1~tty7) after the system starts, and executing any commands to start the follow-up program; the greeter is to select the X/wayland environment, enter passwords for the user, and other external page functions that interact with the user. The greeter will always let I think of the front desk of the hotel, there are waiters and a painting of the Huangshan Welcoming Pine. If you really can't understand, ignore the difference, anyway, it is the last step for the system to let you enter Gnome/KDE/Labwc, etc.

save the world

Finally, configuring the login manager is still risky. When you start configuring greetd, it is not allowed to restart because you may not have configured greeter. In that case, users who do not understand deeply may be very angry because they cannot enter the system.

However, humans are not machines, and it is easy to make mistakes in configuration and other operations, once you encounter cannot log in to the graphical interface.

    1. Remember to press Ctrl + Alt + F1~F7, generally there are 7 ttys in the system, assuming you are currently crashed in tty2, press Ctr + alt + F1 to switch to tty1, enter the user name and password, at this time still Just be able to enter the terminal interface and find a way to fix the error.
    1. If you really can't fix it, and don't want to bother, don't panic, just reinstall the original login manager, assuming it is a Gnome environment:
    1sudo apt reinstall gdm3
    

    It's like being hurt outside, calling your parents to go home, quit playing, showdown.

    1. The head iron still wants to continue, but step 1 doesn't work. This situation is really broken, even if it stays on that interface in an infinite loop, and restarting it doesn't work.

      I encountered this kind of thing when I was tossing LightDM, and I was frightened for a moment. After all, the computer can’t operate anything, just like scrap iron bricks.

      In fact, at this time, there is still a rescue: Just use another computer to log in remotely via ssh. If your sshd remote login is not turned on, it is estimated that you can only mount the file system on the boot disk to save it, which will take a lot of time (at this time, the ip address can be checked through routers/packet capture, etc.).

In short, it is better to choose a more stable login manager. After all, no one wants to lock themselves out, but don’t be too afraid. Generally speaking, 1 and 2 can save you, and some login managers have a debugging mode. Just for the sake of less troubles in the world, I share my personal experience, maybe it can help someone who is destined.

Lastmod: Friday, February 23, 2024

See Also:

Translations: