LinuxCommandLibrary

swaylock

Lock your Sway window manager session

TLDR

Lock the screen using the config in $HOME/.swaylock/config or $XDG_CONFIG_HOME/swaylock/config

$ swaylock
copy

Lock the screen with a simple color background (rrggbb format)
$ swaylock [[-c|--color]] [0000ff]
copy

Lock the screen with a background image
$ swaylock [[-i|--image]] [path/to/image]
copy

Lock the screen and disable the unlock indicator (removes feedback on keypress)
$ swaylock [[-u|--no-unlock-indicator]]
copy

Detach from the controlling terminal after locking (like i3lock)
$ swaylock [[-f|--daemonize]]
copy

Lock the screen with a background image tiled over all monitors
$ swaylock [[-i|--image]] [path/to/image] [[-t|--tiling]]
copy

Lock the screen and show the number of failed login attempts
$ swaylock [[-F|--show-failed-attempts]]
copy

Load the configuration from a specific file
$ swaylock [[-C|--config]] [path/to/config]
copy

SYNOPSIS

swaylock [options]

PARAMETERS

-s, --socket <path>
    Specifies the Wayland socket to connect to, overriding the default. Useful for non-standard setups.

-c, --config <path>
    Loads configuration options from the specified file. Default path is typically ~/.config/sway/swaylock/config.

-C, --no-config
    Prevents swaylock from loading any configuration file, relying solely on command-line arguments.

-u, --show-failed-attempts
    Displays a counter or indicator for the number of failed authentication attempts.

-e, --indicator-caps-lock
    Shows an indicator on screen if the Caps Lock key is active.

-i, --image <path>
    Sets a background image for the lock screen. Can be specified multiple times for different outputs (monitors).

-m, --mode <mode>
    Determines how the background image is displayed (e.g., fill, fit, stretch, tile, center).

--color <color>
    Sets a solid background color for the lock screen. Color is specified in hexadecimal format (e.g., #RRGGBB or #AARRGGBB).

--ring-color <color>
    Sets the color of the authentication indicator ring.

--inside-color <color>
    Sets the color of the inside part of the authentication indicator.

--text-color <color>
    Sets the color of the text displayed on the lock screen, such as the password prompt.

-f, --font <font>
    Specifies the font to use for all text displayed by swaylock.

-t, --font-size <size>
    Sets the font size for the selected font.

-P, --password-request-text <text>
    Customizes the text displayed when swaylock prompts for a password.

-w, --daemonize
    Detaches swaylock from the terminal and runs it in the background after starting.

-h, --help
    Displays a help message and exits.

-v, --version
    Prints the version information and exits.

DESCRIPTION

swaylock is a lightweight and secure screen locker specifically designed for the Wayland display server protocol. It is part of the Sway window manager ecosystem but can be used independently with other Wayland compositors. When activated, swaylock obscures the screen, preventing access until the correct password is provided. It focuses on minimal features to maintain a small attack surface, offering customizable visuals such as background images, colors, font styles, and indicator appearance for user feedback during authentication. Its primary purpose is to protect your session from unauthorized access when you step away from your computer.

CAVEATS

swaylock is designed for Wayland compositors. It will not work with X11-based display servers. Ensure your system's PAM (Pluggable Authentication Modules) configuration is correctly set up for user authentication, as swaylock relies on it. Incorrect PAM configuration can prevent unlocking or lead to security vulnerabilities. Multi-monitor setups may require specifying images per output using multiple --image arguments, or a single background color/image will span all outputs.

CUSTOMIZATION THROUGH CONFIGURATION FILE

While many options can be passed via command-line arguments, swaylock strongly encourages the use of a configuration file (typically ~/.config/sway/swaylock/config) for persistent settings. This allows users to define complex visual styles and behaviors without lengthy command-line invocations. The configuration file uses a simple key-value pair format, making it easy to manage a personalized lock screen appearance.

SECURITY CONSIDERATIONS

swaylock is built with security in mind, leveraging PAM for authentication. It avoids unnecessary features to minimize its attack surface. However, its effectiveness relies on a well-configured PAM system and strong user passwords. Users should ensure their system is up-to-date and follows best security practices. It also supports optional key repeat disabling to prevent potential side-channel attacks during password entry.

HISTORY

swaylock emerged as a core component of the Sway window manager project, an i3-compatible Wayland compositor. As Wayland gained traction and desktop environments moved away from X11, the need for native Wayland-based tools became apparent. swaylock was developed from scratch to provide a simple, secure, and Wayland-native screen locking solution, reflecting the minimalist and functional design philosophy of Sway itself. Its development is closely tied to the evolution of the Sway project, ensuring compatibility and integration with the Wayland ecosystem.

SEE ALSO

sway(1), grim(1), slurp(1), wl-clipboard(1)

Copied to clipboard