jD91mZM2/xidlehook

--not-when-cpu-busy

Closed this issue · 4 comments

cyplo commented

Hi ! I love the project, thank you for that :)

I was thinking about a feature I would love to have - --not-when-cpu-busy or something similar.
It would only execute the command when cpu average is below some percentage.
What do you think ?

If this seems like a good idea - I may have a PR for that some time in the future, but also feel free to pick this up whenever if someone wants :)

thanks again !

I wouldn't use it personally but if you see a use-case for this, feel free to PR (or wait long enough for me to find time to add this)

cyplo commented

Thanks for that :)
My usecase is I would like to leave the laptop unattended while compiling but want for it to go to sleep when done.

@cyplo take a look at my newly released utility caffeinate which might work for your use case. Namely you could likely wire it up to the pid of your compilation process:

caffeinate --pid <compilation_process_pid> --quit=sleep

xidlehook has been rewritten to be a library (see !6). This lets you register any kind of timer using traits. Feel free to PR something that adds such a module, extend xidlehook yourself using the awesome library system. Or just use caffeinate :)