HYPRLAND with swaylock and wlogout. Beautiful logout menu and lock screen automated with swayidle

3 min read 6 hours ago
Published on Jan 20, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

In this tutorial, we will integrate the logout menu wlogout and the lock screen swaylock into your Hyprland configuration. We will automate the start of swaylock using swayidle, enhancing your system’s security and usability. This setup allows for a customizable logout experience and an efficient locking mechanism for your Wayland environment.

Step 1: Install Required Packages

Before configuring your environment, you need to install the necessary packages.

  1. Install wlogout

    • Wlogout is a customizable logout menu for Wayland.
    • You can find it on GitHub.
    • Use your package manager to install it. For example:
      sudo apt install wlogout
      
  2. Install swaylock

    • Swaylock is a screen locking utility compatible with Wayland.
    • Visit the swaylock GitHub page for more details.
    • Install it using:
      sudo apt install swaylock
      
  3. Install swaylock-effects

    • This is a fork of swaylock that includes additional effects.
    • Check it out on GitHub.
    • Install it with:
      sudo apt install swaylock-effects
      
  4. Install swayidle

    • Swayidle is an idle management daemon for Wayland compositors.
    • More information is available on its GitHub page.
    • Install it using:
      sudo apt install swayidle
      

Step 2: Configure wlogout

After installing wlogout, you can customize its appearance to fit your setup.

  1. Create a style.css file

    • This file allows you to change the appearance of the logout menu.
    • You can place it in your configuration folder, usually located at ~/.config/wlogout/style.css.
  2. Edit the style.css file

    • Customize your logout menu by editing the CSS properties. Here are some examples:
      background-color: #282c34;
      color: #ffffff;
      font-size: 16px;
      
    • Adjust these settings to match your preferred look and feel.

Step 3: Set Up swaylock

Configuring swaylock is essential for locking your screen.

  1. Configure swaylock options

    • Open your sway configuration file, typically located at ~/.config/sway/config.
    • Add the following line to set swaylock as your screen locker:
      exec swaylock
      
  2. Test swaylock

    • You can test swaylock by running it from the terminal:
      swaylock
      

Step 4: Automate swaylock with swayidle

To automatically lock your screen after a period of inactivity, you will set up swayidle.

  1. Edit your sway configuration

    • In the same ~/.config/sway/config file, add the following lines:
      exec swayidle -w \
        timeout 300 swaylock -f; \
        timeout 600 'your-command-to-run-on-idle'
      
    • This example locks the screen after 5 minutes (300 seconds) of inactivity and can run additional commands after 10 minutes (600 seconds).
  2. Test swayidle

    • Restart sway and ensure that swayidle is running as expected.

Conclusion

You have successfully integrated wlogout and swaylock into your Hyprland configuration, along with automating the screen lock feature with swayidle. This setup enhances both security and usability in your Wayland environment.

For further customization, explore additional options in the wlogout and swaylock documentation. Happy customizing!