jD91mZM2 / xidlehook

GitLab: https://gitlab.com/jD91mZM2/xidlehook
MIT License
382 stars 33 forks source link

Xidlehook socket api ignores timers #60

Closed Meister1593 closed 3 years ago

Meister1593 commented 3 years ago

I use xidlehook on daily basis and i think it's awesome tool for non-de systems (in my case - awesomewm) Basically what i do is run xidlehook on background and talk to socket api with hotkeys on my wm My problem is, whenever i use socket api, for example to trigger lock, after first timer passes, it would re-open my lock script again, instead of continuing to second script (which is turning display off) What i want is to make sure that after trigger lock, it would go for second timer and not for second lock re-open (first timer).

Script that i use for xidlehook on my wm: https://github.com/Meister1593/UsefulScripts/blob/master/screen_lock_xidlehook.sh What i use to trigger xidlehook: xidlehook-client --socket /home/plyshka/xidlehook.socket control --action trigger --timer 0

jD91mZM2 commented 3 years ago

Thanks for reporting! I think it should be fixed on master now? :)

Meister1593 commented 3 years ago

Yes, it works, but i found one another thing When it locks and goes away (both timers are executed, everything is fine), and when i move mouse, it triggers reset timer for whole sequence on xidlehook Which means, it will try to open program under timer1 and timer2, even if timer1 is already executed Maybe adding an option for triggering only 2 timer (or any starting off by choise) after mouse movement (or any activity) and not the whole sequence? I might create new issue for this

jD91mZM2 commented 3 years ago

Sounds like you should run xidlehook with --once and launch the second timer from the first timer's handler.

Meister1593 commented 3 years ago

Sounds like you should run xidlehook with --once and launch the second timer from the first timer's handler.

Can you give me an example? i can't think of how it would work.

jD91mZM2 commented 3 years ago
xidlehook --once --timer 5 "\
  echo first timer \
    && xidlehook --once --timer 5 \"echo second timer\" \"\" \
" ""
Meister1593 commented 3 years ago
xidlehook --once --timer 5 "\
  echo first timer \
    && xidlehook --once --timer 5 \"echo second timer\" \"\" \
" ""

and whole thing don't even need to use socket api since it's a single-use thing? Wouldn't it mean that it won't work on background and check for activity after second timer passed? P.S using that script it would print out both timers at once after first 5 seconds

jD91mZM2 commented 3 years ago

Wouldn't it mean that it won't work on background and check for activity after second timer passed?

Not sure I understand what you mean?

P.S using that script it would print out both timers at once after first 5 seconds

Oh yeah, that's true. I guess you'll need to use the socket API and call reset-idle before registering the new timer

Meister1593 commented 3 years ago

Wouldn't it mean that it won't work on background and check for activity after second timer passed?

Not sure I understand what you mean?

P.S using that script it would print out both timers at once after first 5 seconds

Oh yeah, that's true. I guess you'll need to use the socket API and call reset-idle before registering the new timer

By that i meant that after this script has done full sequence, it means that i have to restart it again

jD91mZM2 commented 3 years ago

I guess so. xidlehook really isn't designed for your usecase, sorry

Meister1593 commented 3 years ago

I guess so. xidlehook really isn't designed for your usecase, sorry

i thought it was primary use as lock daemon, which in my case is pretty strange behaviour not to do for such daemon Xidlehook running -> no activity for timer 1 time -> timer 1 executes lock -> no activity for timer 2 -> timer 2 executes monitors sleep -> xidlehook sleeps -> user made any activity but it was just to get monitors from sleep (for example, to check clock) -> user leaves -> xidlehook should be aware that timer 1 program is still running and then it should be aware that timer 2 program is not running. In that case it should run timer 2 instead of timer 1 and timer 2 both from beginning. But oh well, i might try to do something like that for myself in xidlehook Is pipewire support considered?

jD91mZM2 commented 3 years ago

Your description does make sense, I'll have to think about that. Right now I'm not incredibly happy with xidlehook's code, so I'll see if I can find a sane way to kill two birds with one stone and add support for this usecase.

Meister1593 commented 3 years ago

Sure, take your time. In any case it's a useful project, it helped me a lot.