Closed David96 closed 2 years ago
Rebased and added checking of the condition every 5s after it first fails. I'm using this for quite a while now therefore marking it ready for review.
I'd rather let scripts do this. For instance:
swayidle -w timeout 300 './idle.sh &' resume 'pkill ./idle.sh'
and
while ! <condition>; do sleep 5; done
<action>
You're right, that sounds like a good solution that I hadn't considered. Only potential issue I see (and I might be totally wrong here because I'm not sure how the wayland listeners work exactly) that this would block swayidle on the waitpid call and therefore would prevent any other timeout commands from being run while waiting for idle.sh. But if you don't see any use in this feel free to close the pr.
this would block swayidle on the waitpid call
The &
should make it so swayidle doesn't wait for the command.
This implements #97.
I made it so the timer is restarted when it gets aborted by the condition. This is of course not perfect since it obviously doesn't react instantly to condition changes. The only way to kind of do that I could think of is if the condition is false once, to periodically check with a short interval (whatever that would be) whether it changed.
Even without the reaction to condition changes I personally find this already quite helpful so my computer doesn't go to standby while I'm listening to some music.
Currently the order of "if" and "resume" is fixed, if has to come before resume, not sure, whether it should be possible to specify those the other way around.