Open zecoj opened 2 years ago
I would also like a hook to attach scripts to waking the device, so I could automatically switch the device to dark mode at night. I looked for a cron option or existing hook to use but couldn't find it.
You might be interested in NickelDBus.
However, I've noticed that the NickelDBus version of NickelMenu is rather out of date, so I might have to do an update over my upcoming long weekend to bring NM up to date.
Thanks for the suggestion! I've actually looked into NickelDBus earlier today (I should have mentioned that!) but couldn't find a hook/event for the wake/sleep of the device or a cron-like feature but admittedly I only looked briefly so I might have missed it. I also couldnt figure out how to actually toggle dark mode from a script, otherwise I figured I could maybe even make a udev rule to trigger a script on the events I see in dmesg when I wake/sleep the device.
A lack of dark mode is a consequence of the aforementioned out of date NickelMenu in NDB.
As far as wake/sleep goes, I'm not sure how useful that will be. Sleep is probably doable, but waking (from suspend) may not be, because I believe Kobo's (eventually) go into a suspend mode that requires button/sleepcover to wake from, although @NiLuJe could say for certain how that works.
Ah oke then I misunderstood!
The idea behind the wake/sleep would be to hook a time check into it; if after 20:00 and before 07:00, enable dark mode. Otherwise, enable light mode
-------- Original Message -------- On 11 Jul 2023, 22:00, Sherman Perry wrote:
A lack of dark mode is a consequence of the aforementioned out of date NickelMenu in NDB.
As far as wake/sleep goes, I'm not sure how useful that will be. Sleep is probably doable, but waking (from suspend) may not be, because I believe Kobo's (eventually) go into a suspend mode that requires button/sleepcover to wake from, although @.***(https://github.com/NiLuJe) could say for certain how that works.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>
I believe Kobo's (eventually) go into a suspend mode that requires button/sleepcover to wake from, although @NiLuJe could say for certain how that works.
Yeah, triggering a wakeup from suspend programmatically would require an rtc alarm (there's probably an internal API for that, though, as Nickel doesn't just call rtcwake (because that doesn't work without a patched rtcwake binary anyway ;p)).
On the other hand, doing something on wakeup, which is what I assumed OP meant here, is another thing entirely ;).
Yes, doing something on wakeup (custom script which checks time and enables/disables dark mode as required) is what I meant here. It seemed like wakeup event would be a sensible place to hook this functionality as it seems cron is not available.
Because of the aforementioned "system is actually in suspend (or standby) 99.9% of the time" thing, a cron wouldn't help you anyway ;).
And the issue with standby is that it happens a lot (basically, after ~6s of inactivity, the device goes asleep), which means, if you can't discriminate wakeup from standby from wakeup from suspend, you'll get a lot of wakeup events.
I haven't looked into that, FWIW, because when I'm working on this stuff, I'm the one triggering the PM entry, so doing something on wakeup is entirely transparent: the next line of code after the PM entry one is what will run on wakeup ;D.
I'd think a small script which only checks the time and current state of fhe display mode could be cheap enough to execute on each wake event, but perhaps I should just accept to do it manually which of course isn't the end of the world, it just feels a bit silly that you can't configure time based dark mode on native kobo. To me it seems like such an obvious feature to add :-)
I wonder if it would be possible to set something up with a QTimer?
That reminds me that there's a fairly clunky way to detect wakeup events outside of Nickel, at least on halfway recent devices (Linux 3.0+), and that's by catching discontinuous clock changes on CLOCK_REALTIME
via a TFD_TIMER_CANCEL_ON_SET
timerfd.
If you like pain and low-level Linux timekeeping shenanigans, NanoClock does that. (It's even more unreadable because FFI! :D).
(To be clear: I really wouldn't recommend doing that. But you can ;p. Also, I may be misrembering how this actually behaves in practice ^^).
In NickelDBus, I should be able to connect to the following signals if any would help:
aboutToSleep()
resumingFromSleep()
resumedFromSleep()
aboutToPowerOff()
aboutToReboot()
resumedFromSleep() sounds exactly like the hook I was looking for. If I could trigger a simple SH script from that event which checks the current time and sets dark mode as needed this should work :-)
It would be nice to be able to launch menu item(s) when NickelMenu is loaded at boot time. Perhaps via a flag in the menu item file to say that this item should be launched automatically.