I think it is very handy that in Power Management, you can run a script when idle. However, it is a bit of a shame there is no possibility to run a script when the user is back.
Should I do a feature request maybe? Can you do that on bugs.kde.org ?
if you run the script at idle, it will “complete” the next part of the script upon wake.
#!/bin/bash
echo "hey it's now $(date)" >> ~/bin/timestamp
sudo systemctl suspend-then-hibernate
sleep 5
echo "but now it's $(date)" >> ~/bin/timestamp
echo "********************" >> ~/bin/timestamp
#this will re-apply the RGB profile to the RAM modules which always wake up in rainbow
~/.local/bin/OpenRGB_0.9_x86_64_b5f46e3.AppImage --profile amber
the timestamp file records the time/date before suspend and then immediately after wake.
then it also runs a script to set the color of my ram sticks after hibernation because when they lose power they go back to rainbow by default.
I hope idle and inactive mean the same thing? As in, no user interaction for x amount of time. Ah but I see, you were thinking of thing like cpu idleness? No, I meant it purely in user activity terms.
I needed something that does something when the system becomes idle (as in me not active for a couple of minutes), and does another thing when I resume my work.
I found the systemctl thing to be a bit of a hassle, and it’s not too clear when or how the idle flags actually flip or not.
I ended up making my own thing, which queries last mouse movement by reading out /dev/input/mice
Indeed, Claude suggested it as well, and it works, but I ended up not using it since it is still not clear how and when the system deems the user inactive.
With the mouse query, I have my exact timings I want. This could be extended to all input devices ofcourse, but the mouse if enough for now.