diff options
author | Arnav Singh <me@arnavion.dev> | 2024-12-22 16:48:06 -0800 |
---|---|---|
committer | Arnav Singh <me@arnavion.dev> | 2025-01-22 08:42:02 -0800 |
commit | 5eb8203f8eba57aca55f67d63b309522c281e353 (patch) | |
tree | 236b2407c527e030fb898f084ace57e3f02c4649 /src | |
parent | 18f6190ff233f06c5a2e825dd0db188bfc52e030 (diff) |
suspend: support logind not sending PrepareForSleep(true)
elogind sends PrepareForSleep(false) when resuming but doesn't necessarily
send PrepareForSleep(true) when sleeping. This means we didn't necessarily
drop our previous inhibitor when it's time to take a new one. So instead of
asserting that we dropped our previous inhibitor, just reuse it.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-sleep-monitor-systemd.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/mm-sleep-monitor-systemd.c b/src/mm-sleep-monitor-systemd.c index 99814386..c432a416 100644 --- a/src/mm-sleep-monitor-systemd.c +++ b/src/mm-sleep-monitor-systemd.c @@ -114,7 +114,12 @@ inhibit_done (GObject *source, static void take_inhibitor (MMSleepMonitor *self) { - g_assert (self->inhibit_fd == -1); + if (self->inhibit_fd != -1) { + // logind didn't send us a `PrepareForSleep(true)` so we didn't drop our previous inhibitor. + // Just reuse it. + mm_obj_warn (self, "logind did not send sleep notification! Taking over existing inhibitor."); + return; + } mm_obj_dbg (self, "taking systemd sleep inhibitor"); g_dbus_proxy_call_with_unix_fd_list (self->sd_proxy, |