Closed thesquash closed 1 year ago
What happens with this if someone not using systemd has the old version of ConsoleKit installed? Does the clock just fail to update on resume or does the applet crash?
Also what are the odds of mate-panel 1.28 and the old version of ConsoleKit ever coexisting? This may not matter but if it does and if the applet crashes with old Consolekit either dependencies should be updated or the "neither" case caught. If the applet keeps running or the odds of the above coexisting are nil we can proceed to merge this with no further changes
In the event that the MATE Panel with this commit applied is used with the original ConsoleKit (or a sufficiently old pre-release version of ConsoleKit2), the Clock Applet will act as it used to: It will not automatically update when the computer comes out of suspend mode, but will otherwise work as expected. I was very careful to implement this feature in such a way that the Clock Applet will fall back to its old behavior if no system manager (logind
or ConsoleKit2) can be contacted or if the login manager doesn't emit the required signal upon exiting sleep mode.
And regarding your original comment: Yes, it's true, the Clock Applet might not instantaneously update when you resume the computer from sleep mode, but that is only because the Linux kernel freezes all processes before entering sleep mode, and unfreezes them only after all steps in the resume process have been executed. That's why the mouse pointer is frozen initially too: The X server is a process like any other, and the kernel freezes it to make handling sleep mode easier. Imagine saving the state of all applications, while the applications were still actively running and changing their state!
TL;DR: Neither issue you mentioned is even a bug or an issue. If somebody wants to test my claims about the original ConsoleKit, though, feel free. I tried it (as improbable as that sounds), but I know I make mistakes, and I want others to find my mistakes. If I didn't make mistakes, I would have just merged this changed myself.
Thanks as always.
Hoping we can get another review on this. Looks like you've really done your homework on testing this, but more eyes on new code is desirable especially when code gets a bit more complex then the common simple changes and one-liners.
Before this commit, the Clock Applet was unaware of when the system resumed from sleep mode (e.g. suspend or hibernate). This meant that, if the user suspended the system and then woke it up some time later, the clock might not show the real current time, but instead would continue to show the time at which the system was suspended for up to a minute after the system woke up. This could be confusing to the user if they peered up at the clock immediately after, say, opening their laptop lid.
This commit connects to ConsoleKit or (if available) systemd-logind via D-Bus, and listens for a signal that indicates when the system wakes up from sleep mode. When the system does wake up, the Clock Applet updates the date/time immediately, and also updates all the weather/temperature readings if possible.
Note that if logind is missing, ConsoleKit2 is required for this feature to work; the original ConsoleKit lacked the signal required to implement this feature. This should not be a problem since it is unlikely that anyone would even consider using the original ConsoleKit in this day and age.
Fixes #481.