Swaylock: Difference between revisions
mNo edit summary |
→Configuration: add note on suspend/timeout |
||
| Line 55: | Line 55: | ||
+ builtins.readFile ./swaylock; | + builtins.readFile ./swaylock; | ||
}} | }} | ||
=== Locking on suspend/timeout (swayidle) === | |||
While swaylock works in isolation, it might be desirable to use it in conjunction with [[Swayidle]] to lock after a timeout or on suspend. | |||
When swayidle is configured to trigger <code>swaylock</code> on a <code>lock</code> event, it's also possible to use <code>loginctl lock-session</code> to lock the session. | |||
== Forks == | == Forks == | ||
Latest revision as of 05:54, 3 September 2026
Swaylock is a screen locking utility for Wayland compositors.
Installation
Standalone
environment.systemPackages = with pkgs; [
swaylock
];
Home Manager - Standalone
programs.swaylock.enable = true;
Home Manager - Through Sway
programs.sway.extraPackages = with pkgs; [swaylock];
programs.sway.enable) you need to set security.pam.services.swaylock = {}; manually.Configuration
Swaylock may be configured using Home Manager, options may be found under the Home Manager Appendix - programs.sway.enable.
programs.swaylock = {
enable = true;
settings = {
color = "808080";
font-size = 24;
indicator-idle-visible = false;
indicator-radius = 100;
line-color = "ffffff";
show-failed-attempts = true;
};
};
If you would like to use a config file instead you may instead specify a config file.
xdg.configFile."swaylock/config".source = ./swaylock-theme;
Adding background
You can add background declaratively using fetchurl similar to Wallpapers for Wayland. In this example, a wallpaper in nixos-artwork is set to image attribute and the remaining configuration from ./swaylock are merged.
xdg.configFile."swaylock/config".text =
let
src = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/NixOS/nixos-artwork/8957e93c95867faafec7f9988cedddd6837859fa/wallpapers/nix-wallpaper-binary-black.png";
sha256 = "0v3111a1ihsh4ajijbjh6y7a8p5cb5g3rdxqjbzx37pn1k9s254s";
};
in
''
image=${src}
''
+ builtins.readFile ./swaylock;
Locking on suspend/timeout (swayidle)
While swaylock works in isolation, it might be desirable to use it in conjunction with Swayidle to lock after a timeout or on suspend.
When swayidle is configured to trigger swaylock on a lock event, it's also possible to use loginctl lock-session to lock the session.
Forks
swaylock-effects allows built-in screenshots and image manipulation effects like blurring.
programs.swaylock.package = pkgs.swaylock-effects;