hyprwm / hypridle

Hyprland's idle daemon
BSD 3-Clause "New" or "Revised" License
404 stars 25 forks source link

Caffeine-NG expects a different DBus Service Architecture than Hypridle's #44

Closed rgarber11 closed 6 months ago

rgarber11 commented 7 months ago

I recently switched to hypridle, and wanted to continue using caffeine-ng for idle inhibition. However, while chromium's idle inhibit was successful, caffeine-ng's is not. Looking at caffeine-ng's code:

...
    def inhibit(self, reason=INHIBITION_REASON) -> None:
        self.__proxy = self.bus.get_object(
            "org.freedesktop.ScreenSaver",
            "/ScreenSaver",
        )
        self.__proxy = dbus.Interface(
            self.__proxy,
            dbus_interface="org.freedesktop.ScreenSaver",
        )
        self.__cookie = self.__proxy.Inhibit("Caffeine", INHIBITION_REASON)

        self.running = True

...

They try to get a ScreenSaver/ object from the root service, then access the org.freedesktop.ScreenSaver interface with inhibit and uninhibit from that. On HyprIdle (and I suspect in the standard), there is instead an org/freedesktop/ object, which then contains the same interface. If this is more a problem with caffeine-ng, feel free to close this, and I'll open one with them. I suspect this might be some of the reason why others are having some trouble with idle inhibition.

rgarber11 commented 7 months ago

I will note the two linked reference implementations of the interface have both paths. (Though KDE's is a dead link, and GNOME's hasn't been updated in years, so I have no clue what the lay of the land is)

yawor commented 6 months ago

The /ScreenSaver path seems to be some historic, legacy one. The standard says about the /org/freedesktop/ScreenSaver.

From what I can see in the code, this should be fairly easy to add. Just create another ScreenSaver object in CHypridle::setupDBUS() with the other path. The m_sDBUSState struct would need some changes though, to store more than one object reference (either change it to std::vector or just add another field in the struct as there probably won't be more than 2 anyway).