KrisDewa
#lockscreen#linux#niri#swayidle

How To Configure Niri / Noctalia Quickshell Config For Automatic Lock Screen on Linux

A step-by-step guide to setting up Niri / Noctalia Quickshell configuration for automatic lock screen using Swayidle on Linux.

In this guide, we will walk you through the process of configuring Niri / Noctalia Quickshell to automatically lock your screen using Swayidle tested on Pika Linux. This setup ensures that your system remains secure when you’re away.

And this guide assumes you have already installed Niri / Noctalia Quickshell and are using a graphical session on Linux. If you haven’t set up Niri yet, please refer to the official documentation for installation instructions.

#Step 1: Install Swayidle

sudo apt install swayidle

#Step 2: Create a folder for the Swayidle service

mkdir -p ~/.config/systemd/user

#Step 3: Create the Swayidle service file

nano ~/.config/systemd/user/swayidle.service

Then, add the following content to the swayidle.service file:

[Unit]
Description=SwayIdle Service
After=graphical-session.target

[Service]
Type=simple
ExecStart=/usr/bin/swayidle -w \
  timeout 300 '"/usr/bin/qs" "-c" "noctalia-shell" "ipc" "call" "lockScreen" "lock"' \
  timeout 600 'niri msg action power-off-monitors' \
  resume 'niri msg action power-on-monitors' \
  timeout 18000 '"/usr/bin/qs" "-c" "noctalia-shell" "ipc" "call" "sessionMenu" "lockAndSuspend"'
Restart=on-failure
TimeoutSec=30

[Install]
WantedBy=graphical-session.target

#Step 4: Enable and Start the Swayidle Service

add the swayidle service to the niri service so that it starts automatically when you log in:

systemctl --user add-wants niri.service swayidle.service

Then, reload the systemd user daemon and enable the swayidle service:

systemctl --user daemon-reload
systemctl --user enable swayidle.service
systemctl --user start swayidle.service
systemctl --user status swayidle.service

#Conclusion

With these steps, you have successfully configured Niri / Noctalia Quickshell to automatically lock your screen using Swayidle on Linux. This setup will help keep your system secure when you’re away, ensuring that unauthorized users cannot access your desktop.

Share this post