feat(power): logout via loginctl, not Niri-locked
Default `loginctl terminate-session $XDG_SESSION_ID`; `logout_command` TOML override for other compositors.
This commit is contained in:
@@ -1,57 +1,29 @@
|
||||
# Moonset
|
||||
|
||||
## Project
|
||||
Wayland session power menu, part of the Moonarch ecosystem.
|
||||
Keybind-invoked overlay with 5 actions: Lock, Logout, Hibernate, Reboot, Shutdown.
|
||||
|
||||
Moonset is a Wayland session power menu, built with Rust + gtk4-rs + gtk4-layer-shell.
|
||||
Part of the Moonarch ecosystem. A keybind-invoked overlay with 5 actions:
|
||||
Lock, Logout, Hibernate, Reboot, Shutdown.
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- Rust (edition 2024), gtk4-rs 0.11, glib 0.22
|
||||
- gtk4-layer-shell 0.8 for the Wayland Layer Shell (OVERLAY layer)
|
||||
- `cargo test` for unit tests
|
||||
|
||||
## Project Structure
|
||||
|
||||
- `src/` — Rust source code (main.rs, power.rs, i18n.rs, config.rs, users.rs, panel.rs)
|
||||
- `resources/` — GResource assets (style.css, default-avatar.svg)
|
||||
- `config/` — example configuration files
|
||||
Stack: Rust / gtk4-rs / gtk4-layer-shell (OVERLAY layer). Versions live in `Cargo.toml`.
|
||||
|
||||
## Commands
|
||||
|
||||
```bash
|
||||
# Run tests
|
||||
cargo test
|
||||
|
||||
# Release build
|
||||
cargo build --release
|
||||
|
||||
# Start the power menu (in a Niri session)
|
||||
LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so ./target/release/moonset
|
||||
cargo test # unit tests
|
||||
cargo build --release # release build
|
||||
LD_PRELOAD=/usr/lib/libgtk4-layer-shell.so ./target/release/moonset # run (in Niri)
|
||||
```
|
||||
|
||||
## Architecture
|
||||
## Source (`src/`)
|
||||
|
||||
- `main.rs` — entry point, GTK app, Layer Shell setup, multi-monitor, systemd journal logging, debug level via the `MOONSET_DEBUG` env var, central `GRESOURCE_PREFIX` constant
|
||||
- `power.rs` — 5 power-action wrappers with absolute paths and a 30s timeout (lock, logout, hibernate, reboot, shutdown)
|
||||
- `i18n.rs` — locale detection and string tables (DE/EN)
|
||||
- `config.rs` — TOML config + wallpaper fallback
|
||||
- `main.rs` — entry point, GTK app, Layer Shell, multi-monitor, journal logging (`MOONSET_DEBUG`), `GRESOURCE_PREFIX`
|
||||
- `power.rs` — 5 power-action wrappers (absolute paths, 30s timeout)
|
||||
- `panel.rs` — GTK4 UI (action buttons, inline confirmation, WallpaperWindow)
|
||||
- `users.rs` — user detection, avatar loading (AccountsService, ~/.face, GResource fallback)
|
||||
- `resources/style.css` — GTK theme colors for consistency with the active desktop theme
|
||||
- `config.rs` — TOML config + wallpaper fallback
|
||||
- `i18n.rs` — locale detection, DE/EN string tables
|
||||
|
||||
## Design Decisions
|
||||
`resources/` holds the GResource bundle (style.css, default-avatar.svg); `config/` holds example configs.
|
||||
|
||||
See `DECISIONS.md` for the full decision log.
|
||||
## Decisions
|
||||
|
||||
Summary of the most important decisions:
|
||||
- **OVERLAY instead of TOP layer**: Waybar sits on TOP, moonset must be above it
|
||||
- **Niri-specific logout** (`niri msg action quit`): Moonarch commits firmly to Niri
|
||||
- **Single launch per keybind**: no daemon, the GTK `application_id` prevents double launch
|
||||
- **System icons**: Adwaita/Catppuccin provide all required symbolic icons
|
||||
- **Lock without confirmation**: lock is immediately reversible, needs no confirm
|
||||
- **Absolute paths for binaries**: `/usr/bin/systemctl` etc. instead of relative paths (security)
|
||||
- **GResource bundle**: CSS and default avatar are compiled into the binary (the wallpaper comes from the filesystem)
|
||||
- **Async power actions**: `glib::spawn_future_local` + `gio::spawn_blocking` with a 30s timeout
|
||||
- **Journal logging**: `systemd-journal-logger` instead of file logging — `journalctl -t moonset`, debug level via the `MOONSET_DEBUG` env var
|
||||
See `DECISIONS.md` for the full decision log (layer choice, Niri logout, async power actions, journal logging, …).
|
||||
|
||||
Reference in New Issue
Block a user