session: use systemctl for power verbs, not loginctl
loginctl manages sessions/users/seats only — `loginctl poweroff` exits 1 "Unknown command verb". Preferring it silently broke poweroff/reboot/ suspend/hibernate from every shell surface. Use systemctl; fall back to loginctl only on elogind systems where it does carry power verbs. The logind D-Bus capability probe (CanPowerOff etc.) is unchanged — logind owns policy, systemctl carries out the action.
This commit is contained in:
parent
e3cf50bf75
commit
d027251024
1 changed files with 13 additions and 4 deletions
|
|
@ -170,12 +170,21 @@ Singleton {
|
||||||
// caller can distinguish "started" from "succeeded".
|
// caller can distinguish "started" from "succeeded".
|
||||||
property var lastAction: ({ action: "", status: "idle", exitCode: null })
|
property var lastAction: ({ action: "", status: "idle", exitCode: null })
|
||||||
|
|
||||||
// Prefer logind (owns the session, works under elogind) and fall back to
|
// systemctl owns the power verbs, NOT loginctl. loginctl only manages
|
||||||
// systemctl. Returns [] when neither exists, which callers treat as a
|
// sessions/users/seats — `loginctl poweroff` exits 1 with "Unknown
|
||||||
// refusal rather than firing a command that cannot work.
|
// command verb" (verified on systemd 261, and its --help lists no power
|
||||||
|
// commands at all). Preferring loginctl here silently broke poweroff,
|
||||||
|
// reboot, suspend and hibernate from every shell surface: the button
|
||||||
|
// fired, the Process exited 1, and the phone stayed on (2026-07-20).
|
||||||
|
//
|
||||||
|
// The capability probe still asks logind over D-Bus (CanPowerOff etc.) —
|
||||||
|
// that part was always right; logind owns the *policy*. It just isn't
|
||||||
|
// the CLI that carries out the action.
|
||||||
function powerCommand(action) {
|
function powerCommand(action) {
|
||||||
if (root.hasLoginctl) return ["loginctl", action];
|
|
||||||
if (root.hasSystemctl) return ["systemctl", action];
|
if (root.hasSystemctl) return ["systemctl", action];
|
||||||
|
// elogind ships loginctl with power verbs and usually no systemctl;
|
||||||
|
// only reachable on such a system, where these verbs do exist.
|
||||||
|
if (root.hasLoginctl) return ["loginctl", action];
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue