Skip to content

Latest commit

 

History

History
224 lines (178 loc) · 8.87 KB

README.md

File metadata and controls

224 lines (178 loc) · 8.87 KB

codam-web-greeter

A greeter theme for nody-greeter/web-greeter in LightDM, made specifically for Codam Coding College.


Features

  • Responsive design
  • Display upcoming events and exams from the Intranet
  • Prevent students from signing in with their regular account during exams
  • Customizable background image and logo
  • Greeter can be used as a lock screen when someone is already logged in (replacement for ft_lock)
  • Automatically log students out after 42 minutes of inactivity, either in-session or on the lock screen
  • Display user's profile picture (from ~/.face) on the lock screen
  • Display user's Gnome wallpaper on the lock screen
  • Keybinding to gracefully reboot the computer (Ctrl+Alt+Del)
  • Display network status on-screen without having to log in
  • Custom screensaver support (HTML5 canvas)

Screenshots

Login screen Lock screen

Installation

Caution: make sure you know how to restore your system if something goes wrong. This theme is made specifically for Codam and might not always work as intended in other 42 schools, let alone different environments. For 42 schools, it is recommended to install this theme using the provided Ansible role on ansiblecluster.

  1. Install dependencies:
sudo apt install lightdm light-locker xprintidle
  1. Install nody-greeter by downloading the deb from the nody-greeter repository releases page. If you're at a 42 school, it is recommended to add this deb to your Nexus server so you can easily install it using apt later. Alternatively, you can install it by compiling from source (don't forget to clone the repository with the --recursive flag to include its submodules).

  2. Download the latest stable release of the greeter theme from the releases page:

wget https://github.com/codam-coding-college/codam-web-greeter/releases/latest/download/codam-web-greeter.zip
unzip codam-web-greeter.zip
  1. Install the greeter theme:
install -dm755 /usr/share/web-greeter/themes/codam
cp -r codam-web-greeter /usr/share/web-greeter/themes/codam
bash /usr/share/web-greeter/themes/codam/systemd/install.sh
  1. Enable the nody-greeter greeter in LightDM by editing /etc/lightdm/lightdm.conf:
# Add the following line to the file under [SeatDefaults]:
greeter-session=nody-greeter
  1. Enable the greeter theme in nody-greeter by editing /etc/lightdm/web-greeter.yml:
# Replace the theme name with codam-web-greeter:
greeter:
    theme: codam
  1. Restart LightDM:
sudo systemctl restart lightdm

Development

Client

Use the provided Makefile to build the theme:

make

You can optionally build the theme in light mode:

make CLIENT_THEME=light

Or in light mode with a boxed form to make the login/unlock form more readable:

make CLIENT_THEME=light CLIENT_THEME_BOXED=boxed

Debugging the client

You can then open the static/index.html file in your browser to do some basic editing, but for most things you'll want to install the greeter on your system and run it in debug mode.

Add the following line to /usr/share/xsessions/ubuntu.desktop:

X-LightDM-Allow-Greeter=true

This will allow you to run the greeter in debug mode while logged in as a regular user by installing the greeter like normally and running the following command:

nody-greeter --d

You can then open the Developer Tools sidebar from the greeter's menu and view the console output for any warnings and/or errors.

Do not forget to remove the line from /usr/share/xsessions/ubuntu.desktop after you're done debugging - it's a security risk to allow the greeter to be run by regular users.

Server

Use the provided Makefile to build the server or use the docker-compose file in the server/ directory directly:

# Makefile method
make server

# Docker-compose method
cd server
docker compose up

Troubleshooting

Locking the screen doesn't work at all

Make sure the LightDM config allows user-switching. Add the following line to /etc/lightdm/lightdm.conf:

[SeatDefaults]
...
allow-guest=false
allow-user-switching=true
greeter-hide-users=true
greeter-show-manual-login=true

Also, make sure you have the light-locker package installed on your system.

Locking the screen shows the login screen

Modify the LightDM hooks.

  • Add the following lines to the greeter setup hook defined in /etc/lightdm/lightdm.conf:
# Get a list of all active user sessions on the system with loginctl
USER_SESSIONS=$(/usr/bin/loginctl list-sessions --no-legend | /usr/bin/awk '{print $3}')

# Loop over all sessions and cache them with dbus-send
# This is required for the codam-web-greeter and other lock screens to work properly (fetch the list of users)
for USER in $USER_SESSIONS; do
	# Cache the user
	/usr/bin/dbus-send --system --print-reply --type=method_call --dest=org.freedesktop.Accounts /org/freedesktop/Accounts org.freedesktop.Accounts.CacheUser string:"$USER" || true
done
  • Add the following lines to the logout hook defined in /etc/lightdm/lightdm.conf:
# Uncache the user
/usr/bin/dbus-send --system --print-reply --dest=org.freedesktop.Accounts /org/freedesktop/Accounts org.freedesktop.Accounts.UncacheUser string:$USER || true

LightDM's logout hook is called upon the greeter exiting and starting a user session

Add the following lines to the top of the logout hook defined in /etc/lightdm/lightdm.conf:

# Check if the hook was called from a greeter exiting or a student session exiting
# Display :0 is used for the first greeter and gets reused for the student session.
# Display :1 is used for the second login (user switching, in fact the Codam lock screen).
# We do not allow switching users, so for :1 there is no user session
# to clean up for. Instead, the hook was called to clean up the greeter.
# No cleaning needs to be done for the greeter. So, we simply exit.
# Source: https://www.freedesktop.org/wiki/Software/LightDM/CommonConfiguration/
if [ "$DISPLAY" != ":0" ]; then
	echo "Catched greeter logout event, exiting"
	exit 0
fi

My custom wallpaper or logo doesn't show up

Make sure the folders mentioned for branding in /etc/lightdm/web-greeter.yml exist and contain the correct files.

branding:
    background_images_dir: /usr/share/codam/web-greeter
    logo_image: /usr/share/codam/web-greeter/logo.png
    user_image: /usr/share/codam/web-greeter/user.png

For 42 schools, link /usr/share/42/login-screen.jpg to the /usr/share/codam/web-greeter/login-screen.png. Place your campus's logo in /usr/share/42/logo.png and a default user icon in /usr/share/42/user.png. The background initially set for ft_lock is not used.

The user's profile picture is not displayed on the lock screen

Make sure you install the systemd services included in the greeter theme. One of these services copies the ~/.face file to /tmp for the greeter to use.

The screen blanks on the login screen

This is a known issue with LightDM. To fix it, add the following line to /etc/lightdm/lightdm.conf:

[SeatDefaults]
...
display-setup-script=/usr/bin/xset s off

Alternatively, /usr/bin/xset s off can be added to the greeter setup hook defined in /etc/lightdm/lightdm.conf.

You might also have to disable the screensaver in the web-greeter settings in /etc/lightdm/web-greeter.yml.

The screen blanks on the lock screen

Best solution: use dm-tool switch-to-greeter instead of dm-tool lock to lock the screen.

Alternatively, add the following line to the greeter setup hook defined in /etc/lightdm/lightdm.conf:

/usr/bin/xset dpms force off

However, this will cause the login screen to blank instead.

Rebooting doesn't work in the lock screen

Check if rebooting from the lightdm user is allowed by PolKit. For example, add the following lines to /etc/polkit-1/localauthority/20-org.d/org.freedesktop.login1.pkla:

[Enable reboot by default for lightdm user]
Identity=unix-user:lightdm
Action=org.freedesktop.login1.reboot;org.freedesktop.login1.reboot-multiple-sessions;org.freedesktop.login1.reboot-ignore-inhibit;
ResultAny=yes
ResultInactive=yes
ResultActive=yes

The power button powers off the system when the greeter is active

Modify the logind configuration on what to do when the power button is pressed. For example, add the following lines to /etc/systemd/logind.conf:

[Login]
...
HandlePowerKey=ignore
HandleSuspendKey=ignore
HandleHibernateKey=ignore

Don't forget to restart logind after modifying: sudo systemctl restart systemd-logind