Here's a detailed article on using i3-wm with multiple users in Linux Mint 22 Cinnamon, focusing on i3-lock and dmil3-lock.
Introduction
i3-wm is a popular tiling window manager for Linux. It offers a highly customizable and efficient desktop environment. In a multi-user system, it's essential to provide support for multiple users while maintaining the benefits of i3-wm. This article will guide you through setting up i3-wm with multiple users in Linux Mint 22 Cinnamon, focusing on i3-lock and dmil3-lock.
Prerequisites
Before we begin, ensure you have the following prerequisites:
- A fresh installation of Linux Mint 22 Cinnamon
- User accounts created (
sudo useradd -m username) i3andi3-lockinstalled (sudo apt-get install i3 i3-lock)
Configuring i3 for Multiple Users
By default, i3 is configured in the user's home directory at ~/.config/i3/. To support multiple users, we need to centralize the configuration.
- Create a group for
i3configurations:sudo groupadd i3 - Change the ownership of the
i3configuration directory to the group:sudo chgrp -R i3 ~/.config/i3/ - Change the permissions of the
i3configuration directory to be writable by the group:sudo chmod -R g+w ~/.config/i3/ - Each user should now belong to the
i3group:sudo usermod -aG i3 username - Move the user's local
i3configuration to the centralized location:mv ~/.config/i3/ ~username/.config/i3.local/
Configuring i3-lock for Multiple Users
By default, i3-lock uses the current user's configuration. To support multiple users, we need to modify the i3-lock script.
- Backup the original
i3-lockscript:sudo mv /usr/bin/i3-lock /usr/bin/i3-lock.original - Create a new
i3-lockscript:sudo nano /usr/bin/i3-lock - Replace the content of the script with the following:
#!/bin/bash
# Get the current user
USER=$(whoami)
# Use the centralized i3 configuration
export XDG_CONFIG_HOME=/home/$USER/.config
export XDG_CONFIG_DIRS=/etc/xdg/i3
# Run i3-lock with the user's configuration
exec i3-lock
- Save the file and make it executable:
sudo chmod +x /usr/bin/i3-lock
Configuring dmil3-lock
dmil3-lock is a systemd service that locks the screen when the user logs out. To support multiple users, we need to modify the service file.
- Open the
dmil3-lock.servicefile:sudo nano /lib/systemd/system/dmil3-lock.service - Find the
ExecStartline and modify it to use the user's configuration:
ExecStart=/usr/bin/i3-lock --lock-workspace 1 --no-output --no-bell --force-output --no-demand
- Replace
--no-demandwith--user $USER:
ExecStart=/usr/bin/i3-lock --lock-workspace 1 --no-output --no-bell --force-output --user $USER
- Save the file and reload the systemd daemon:
sudo systemctl daemon-reload
Conclusion
With these changes, i3-wm and dmil3-lock should now support multiple users in Linux Mint 22 Cinnamon. Users can switch between their configurations without affecting others.