feat: separate logind feature from systemd

Move logind-zbus to a dedicated 'logind' feature that is independent
of the 'systemd' feature. This allows non-systemd users (e.g., OpenRC
with elogind) to access lid switch inhibition and lid status detection
without requiring the full systemd stack.

The 'systemd' feature now depends on 'logind' to maintain backward
compatibility, so existing users are unaffected.

Feature configuration:
- default: ["systemd"]
- logind: ["logind-zbus"]
- systemd: ["libsystemd", "logind", "tracing-journald"]

Resolves #2473

Coding-Agent: OpenCode
Model: claude-sonnet-4-5
This commit is contained in:
Anthony T. Lannutti 2026-06-15 00:30:35 -05:00 committed by Jacob Kauffmann
parent dddf51b441
commit 821b431973
4 changed files with 8 additions and 7 deletions

View file

@ -117,7 +117,8 @@ optional = true
[features] [features]
debug = ["egui", "egui_plot", "smithay-egui", "anyhow/backtrace"] debug = ["egui", "egui_plot", "smithay-egui", "anyhow/backtrace"]
default = ["systemd"] default = ["systemd"]
systemd = ["libsystemd", "logind-zbus"] logind = ["logind-zbus"]
systemd = ["libsystemd", "logind"]
profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"] profile-with-tracy = ["profiling/profile-with-tracy", "tracy-client/default"]
profile-with-tracy-gpu = ["profile-with-tracy", "smithay/tracy_gpu_profiling"] profile-with-tracy-gpu = ["profile-with-tracy", "smithay/tracy_gpu_profiling"]

View file

@ -14,7 +14,7 @@ use tracing::{error, warn};
pub mod a11y_keyboard_monitor; pub mod a11y_keyboard_monitor;
use a11y_keyboard_monitor::A11yKeyboardMonitorState; use a11y_keyboard_monitor::A11yKeyboardMonitorState;
#[cfg(feature = "systemd")] #[cfg(feature = "logind")]
pub mod logind; pub mod logind;
mod name_owners; mod name_owners;
mod power; mod power;

View file

@ -1600,7 +1600,7 @@ impl State {
} }
InputEvent::Special(_) => {} InputEvent::Special(_) => {}
InputEvent::SwitchToggle { event } => { InputEvent::SwitchToggle { event } => {
#[cfg(feature = "systemd")] #[cfg(feature = "logind")]
if event.switch() == Some(Switch::Lid) && self.common.inhibit_lid_fd.is_some() { if event.switch() == Some(Switch::Lid) && self.common.inhibit_lid_fd.is_some() {
let backend = self.backend.lock(); let backend = self.backend.lock();
let output = backend let output = backend

View file

@ -116,7 +116,7 @@ use smithay::{
}; };
use tracing::warn; use tracing::warn;
#[cfg(feature = "systemd")] #[cfg(feature = "logind")]
use std::os::fd::OwnedFd; use std::os::fd::OwnedFd;
use std::{ use std::{
@ -292,7 +292,7 @@ pub struct Common {
pub xwayland_shell_state: XWaylandShellState, pub xwayland_shell_state: XWaylandShellState,
pub pointer_focus_state: Option<PointerFocusState>, pub pointer_focus_state: Option<PointerFocusState>,
#[cfg(feature = "systemd")] #[cfg(feature = "logind")]
pub inhibit_lid_fd: Option<OwnedFd>, pub inhibit_lid_fd: Option<OwnedFd>,
pub with_xwayland: bool, pub with_xwayland: bool,
@ -791,7 +791,7 @@ impl State {
pointer_focus_state: None, pointer_focus_state: None,
dbus_state, dbus_state,
#[cfg(feature = "systemd")] #[cfg(feature = "logind")]
inhibit_lid_fd: None, inhibit_lid_fd: None,
with_xwayland, with_xwayland,
@ -816,7 +816,7 @@ impl State {
} }
fn update_inhibitor_locks(&mut self) { fn update_inhibitor_locks(&mut self) {
#[cfg(feature = "systemd")] #[cfg(feature = "logind")]
{ {
use smithay::backend::session::Session; use smithay::backend::session::Session;
use tracing::{debug, error, warn}; use tracing::{debug, error, warn};