From a63f23ef5cd0a768433bd242855cf4fd00103cb3 Mon Sep 17 00:00:00 2001 From: lbellows <19894143+lbellows@users.noreply.github.com> Date: Tue, 15 Sep 2026 09:15:30 -0400 Subject: [PATCH] util: don't wake the display when inhibiting power management on Xfce xfce4-power-manager implements org.freedesktop.PowerManagement.Inhibit by disabling DPMS, which powers a blanked panel back on. Every scheduled refresh therefore lights the monitor of an idle machine, and it stays lit for a full DPMS timeout afterwards. Use a logind block inhibitor on Xfce instead. It blocks sleep and shutdown with no display side effects, and the fd is released automatically if we exit unexpectedly. Falls back to the old interface if logind is unavailable. --- usr/lib/linuxmint/mintUpdate/util.py | 52 +++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/usr/lib/linuxmint/mintUpdate/util.py b/usr/lib/linuxmint/mintUpdate/util.py index e3bbdb79..8aa3e400 100644 --- a/usr/lib/linuxmint/mintUpdate/util.py +++ b/usr/lib/linuxmint/mintUpdate/util.py @@ -51,6 +51,7 @@ def __init__(self, logger=None, window=None): self.logger = logger self.window = window self.cookie = 0 + self.logind_fd = None def _log(self, msg): if self.logger is not None: @@ -87,8 +88,53 @@ def _get_info(self, reason): return name, path, iface, args, uninhibit_method + def _inhibit_logind(self, reason): + """ Blocks sleep and shutdown without touching the display. + + xfce4-power-manager implements org.freedesktop.PowerManagement.Inhibit by + disabling DPMS, which powers a blanked panel straight back on. A scheduled + refresh then wakes an idle machine's monitor every couple of hours. logind + has no display side effects, and the inhibitor fd is dropped automatically if + we exit or crash, so it can't leave the session inhibited either. + """ + try: + bus = Gio.bus_get_sync(Gio.BusType.SYSTEM) + + ret, fd_list = bus.call_with_unix_fd_list_sync( + "org.freedesktop.login1", + "/org/freedesktop/login1", + "org.freedesktop.login1.Manager", + "Inhibit", + GLib.Variant("(ssss)", ("sleep:shutdown", "mintupdate", reason, "block")), + GLib.VariantType("(h)"), + Gio.DBusCallFlags.NONE, + 2000, + None, + None + ) + self.logind_fd = fd_list.get(ret.unpack()[0]) + except GLib.Error as e: + self._log("Could not inhibit sleep and shutdown via logind: %s" % e.message) + return False + + self._log("Inhibited sleep and shutdown") + return True + + def _uninhibit_logind(self): + try: + os.close(self.logind_fd) + except OSError as e: + self._log("Could not release the logind inhibitor: %s" % e) + + self.logind_fd = None + self._log("Resumed power management") + def inhibit(self, reason): - if self.cookie > 0: + if self.cookie > 0 or self.logind_fd is not None: + return + + # Xfce's inhibit interface disables DPMS - see _inhibit_logind(). + if os.environ.get("XDG_CURRENT_DESKTOP") == "XFCE" and self._inhibit_logind(reason): return try: @@ -119,6 +165,10 @@ def inhibit(self, reason): self.cookie = ret.unpack()[0] def uninhibit(self): + if self.logind_fd is not None: + self._uninhibit_logind() + return + if self.cookie <= 0: return