Files
RedBear-OS/local/recipes/system/redbear-sessiond
vasilito 7b8a1b2838 release: open 0.3.2 and sync Cat 1/Cat 2 version labels
New release branch per the release-branch model (operator decision;
local/AGENTS.md reserves branch creation to the operator).

sync-versions.sh, driven by bump-release.sh, rewrites:
  - Cat 1 in-house crates  -> version = 0.3.2
  - Cat 2 upstream forks   -> <upstream-tag>+rb0.3.2

Labels only; no fork source was rebased in this commit. bump-release.sh
reports these forks as having newer upstream tags, to be taken next:
  relibc   0.2.5  -> 0.6.0
  syscall  0.9.0  -> 0.9.1
  libredox 0.1.18 -> 0.1.19
redoxfs and redox-scheme are already current. kernel, bootloader and
installer are 'diverged' in the fork map and stay report-only (manual
rebase); bootloader additionally has no merge-base with upstream.
2026-08-03 11:04:40 +03:00
..

redbear-sessiond

Session manager daemon — D-Bus login1 subset for KWin/Wayland

Status: FEATURE-INCOMPLETE Category: system Build: cargo build --release --manifest-path source/Cargo.toml

Purpose

redbear-sessiond provides a Red Bear-native implementation of the org.freedesktop.login1 D-Bus interface on the system bus. It exposes Manager, Session, and Seat objects that KWin, SDDM, and other Wayland/KDE components expect during the desktop session lifecycle. It replaces systemd-logind with a pure-Rust, zbus-based daemon that integrates directly with Red Bear's ACPI scheme and device filesystem layout.

D-Bus Interface

  • Bus: system
  • Well-known name: org.freedesktop.login1
  • Object paths:
    • /org/freedesktop/login1 — Manager
    • /org/freedesktop/login1/session/c1 — Session
    • /org/freedesktop/login1/seat/seat0 — Seat
    • /org/freedesktop/login1/user/current — User

Manager Interface (org.freedesktop.login1.Manager)

Method Description
ListSessions Returns current session list (uid, username, seat, path)
GetSession(id) Resolves session ID to object path
GetSessionByPID(pid) Resolves PID to session path
ListSeats Returns seat list
GetSeat(id) Resolves seat ID to object path
ListUsers Returns user list (uid, username, path)
GetUser(uid) Resolves UID to user object path
ListInhibitors Lists active sleep/shutdown inhibitors
Inhibit(what, who, why, mode) Registers a shutdown/sleep inhibitor; returns FD
PowerOff(interactive) Writes "shutdown" to /scheme/sys/kstop
Reboot(interactive) Writes "reset" to /scheme/sys/kstop
Suspend(interactive) Writes "s3" to /scheme/sys/kstop
CanPowerOff / CanReboot / CanSuspend Returns "yes" when /scheme/sys/kstop is writable, "na" otherwise
CanHibernate / CanHybridSleep / CanSuspendThenHibernate / CanSleep Returns "na" (not yet implemented)
ActivateSession(id) Activates a session
ActivateSessionOnSeat(id, seat) Activates a session on a specific seat
LockSession / UnlockSession Set/clear locked hint on a session
LockSessions / UnlockSessions Lock/unlock all sessions
TerminateSession(id) Sets session state to "closing"
TerminateUser(uid) Sets session state to "closing" for user
KillSession(id, who, signal) Sends signal to session leader PID
KillUser(uid, signal) Sends signal to user's session leader PID

Properties: IdleHint, IdleSinceHint, IdleSinceHintMonotonic, BlockInhibited, DelayInhibited, InhibitDelayMaxUSec, HandleLidSwitch, HandlePowerKey, PreparingForSleep, PreparingForShutdown

Signals: PrepareForSleep(before: bool), PrepareForShutdown(before: bool), SeatNew, SeatRemoved

Session Interface (org.freedesktop.login1.Session)

Methods: Activate, TakeControl, ReleaseControl, TakeDevice(major, minor), ReleaseDevice(major, minor), PauseDeviceComplete, SetIdleHint, SetLockedHint, SetType, Terminate, Kill

Properties: Active, Remote, Type, Class ("user"), Service ("redbear"), Desktop ("KDE"), Display, Id, State, Seat, User, VTNr, Leader, Audit, TTY, RemoteUser, RemoteHost, IdleHint, LockedHint

Signals: PauseDevice(major, minor, kind), ResumeDevice(major, minor, fd), Lock, Unlock

Seat Interface (org.freedesktop.login1.Seat)

Methods: SwitchTo(vt) — delegates to inputd -A <vt>

Properties: Id, ActiveSession, Sessions, CanGraphical (true), CanTTY (true), IdleHint

Architecture

8 Rust modules composing a single binary:

Module Purpose
main.rs Entry point, argument parsing, D-Bus connection with retry, shutdown signal handling
manager.rs LoginManager — all Manager interface methods, inhibitor lifecycle, signal emission
session.rs LoginSession — all Session interface methods, device control, PauseDevice/ResumeDevice signals
seat.rs LoginSeat — all Seat interface methods, VT switching via inputd
runtime_state.rs SessionRuntime — shared state (session ID, username, UID, VT, inhibitors, idle/lock hints) behind Arc<RwLock<>>
control.rs JSON-over-Unix-socket control channel at /run/redbear-sessiond-control.sock — accepts set_session, reset_session, shutdown, set_inhibit_delay, set_lid_switch, set_power_key, set_last_activity messages
acpi_watcher.rs ACPI edge watcher — polls scheme:kernel.acpi/kstop for shutdown (verb 2) and sleep (verb 3) edges; emits PrepareForShutdown/PrepareForSleep D-Bus signals
device_map.rs (major, minor) → scheme path resolution cache — scans /scheme/drm/, /dev/input/, /dev/fb* at startup; supports lazy single-device resolution and periodic refresh; fallback paths for common major numbers (13=evdev, 226=drm, 29=fb)

Dependencies: zbus v5, tokio (multi-thread runtime), serde/serde_json, libc, libredox, redox_syscall. Uses a vendored tokio patch with Redox-specific epoll recovery for early-boot scheme churn.

Consumers

  • KWin (reads login1 session/seat state via D-Bus)
  • SDDM (registers sessions)
  • redbear-authd (sends set_session / reset_session control messages)
  • KDE Plasma (monitors idle hint, lock state, session lifecycle)

Status Notes

  • login1 Manager interface: 32+ methods implemented. PowerOff/Reboot/Suspend write to /scheme/sys/kstop (Redox kernel stop scheme). Hibernate/sleep variants return "na" until kernel support lands.
  • Inhibitor lifecycle: Fully implemented with Unix pipe FDs. Caller holds one end; daemon holds the other. Caller-closed FDs trigger automatic inhibitor reaping. Background reaper polls NameHasOwner every 2s to detect vanished bus names.
  • Device map: Filesystem-based (major, minor) resolution with no hardcoded entries. Supports lazy resolution via scan_single() and fallback path generation for common device classes.
  • ACPI watcher: On Redox, polls scheme:kernel.acpi/kstop for shutdown/sleep edges. On host (Linux), returns immediately — integration tests exercise the D-Bus signal plumbing without the kernel side.
  • Tests: 30+ unit tests covering manager, session, seat, control message parsing, inhibitor lifecycle, idle/lock hints, and property defaults.
  • Runtime state: Thread-safe behind Arc<RwLock<SessionRuntime>> with manual Clone impl for consistent snapshots.

Cross-reference: local/docs/DBUS-INTEGRATION-PLAN.md