feat(session): read session state and greeter entries from logind

Switching needs to know whether a session owns the seat, is closing, or is
the greeter, and which session file the greeter will list for a desktop.
The catalog now keeps the logind State, exposes targeted lookups, and prefers
the active session so a closing one is never activated. Session ids are
compared numerically without std::stoi.
This commit is contained in:
BlackAngelTV committed 2026-11-04 15:42:22 +01:00
1 parent 265d0f4648
commit f7789cd639
4 files changed
+205 -45

No files matched your search

+25 -3
View File
@@ -46,16 +46,38 @@ bool isDesktopInstalled(const DesktopProfile& profile) {
}
bool findActiveSession(const DesktopProfile& profile, std::string& sessionId) {
// Prefer the session that owns the seat: a stale or closing session of the
// same desktop would activate a VT that has nothing left to draw.
std::string fallback;
for (const SessionInfo& session : listGraphicalSessions()) {
if (session.state == "closing" || session.state == "closing-failed") {
continue;
}
const std::string desktop = lower(session.desktop);
bool matches = false;
for (const std::string& name : profile.sessionNames) {
if (desktop == lower(name)) {
sessionId = session.id;
return true;
matches = true;
break;
}
}
if (!matches) {
continue;
}
if (session.active) {
sessionId = session.id;
return true;
}
if (fallback.empty()) {
fallback = session.id;
}
}
return false;
if (fallback.empty()) {
return false;
}
sessionId = fallback;
return true;
}
std::vector<std::string> installArguments(const DesktopProfile& profile) {