nevaforget e51a847d48 fix: quit in ::unlocked instead of after unlock() (v0.6.17)
The real cause of the unlock SIGSEGV: gtk4-session-lock destroys the lock
windows itself when the lock ends (per its header), so unlock_callback's
`unlock(); app.quit();` destroyed them a second time — surface already gone
→ gdk_surface_get_display NULL → crash in gtk_window_destroy. Reproduces on
a plain single-monitor lock/unlock, no suspend needed.

unlock_callback now calls only unlock(); a new connect_unlocked handler
quits the app after the library finishes teardown. Mirrors the upstream
examples/simple.rs exactly.

Reverts the v0.6.15/v0.6.16 monitor-pruning + LockscreenHandles.monitor:
it was a misdiagnosis (the crash is monitor-independent) and manually
manipulated library-managed lock windows, which the upstream example
explicitly warns against. Monitor removal is left to the library.
2026-06-02 17:19:09 +02:00

Moonlock

A secure Wayland lockscreen with GTK4, PAM authentication and fingerprint support. Part of the Moonarch ecosystem.

Features

  • ext-session-lock-v1 — Protocol-guaranteed screen locking (compositor keeps screen locked on crash, exit(1) in release if unsupported)
  • PAM authentication — Uses system PAM stack (/etc/pam.d/moonlock) with 30s timeout and generation counter
  • Fingerprint unlock — fprintd D-Bus integration with sender validation, async init (window appears instantly), pam_acct_mgmt check after verify, auto-resume on transient errors
  • Multi-monitor + hotplug — Lockscreen on every monitor with shared blur and avatar caches; monitors added after suspend/resume get windows automatically via connect_monitor signal
  • GPU blur — Background blur via GskBlurNode (downscale to max 1920px, configurable 0200)
  • i18n — German and English (auto-detected)
  • Faillock warning — Progressive UI warning after failed attempts, PAM decides lockout
  • Panic safety — Panic hook logs but never unlocks (installed before logging)
  • Password wipingZeroize on drop from GTK entry through PAM FFI layer
  • Journal loggingjournalctl -t moonlock, debug level via MOONLOCK_DEBUG env var

Requirements

  • GTK 4
  • gtk4-session-lock (ext-session-lock-v1 support)
  • PAM (/etc/pam.d/moonlock)
  • Optional: fprintd for fingerprint support

Building

cargo build --release

Installation

# Install binary
sudo install -Dm755 target/release/moonlock /usr/bin/moonlock

# Install PAM config
sudo install -Dm644 config/moonlock-pam /etc/pam.d/moonlock

# Optional: Install example config
sudo install -Dm644 config/moonlock.toml.example /etc/moonlock/moonlock.toml.example

Configuration

Create /etc/moonlock/moonlock.toml or ~/.config/moonlock/moonlock.toml:

background_path = "/usr/share/wallpapers/moon.jpg"
background_blur = 40.0    # 0.0200.0, optional
fingerprint_enabled = true

Usage

Typically launched via keybind in your Wayland compositor:

# Niri keybind example
binds {
    Mod+L { spawn "moonlock"; }
}

Development

cargo test
cargo build --release
LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so ./target/release/moonlock

License

MIT

S
Description
No description provided
Readme 1.2 MiB
Languages
Rust 97.4%
CSS 2.6%