jD91mZM2/xidlehook

No audio detection (Pipewire support)

Opened this issue · 6 comments

So issue is explained by title, xidlehook can't work with pipewire and simply does not detect any audio.
Pipewire has pulse module, most likely issue is that it haven't implemented 100% of pulse api.
I don't know exactly what would be better: to pipewire handle pulse methods properly or to implement pipewire support in xidlehook.
In first case, i think would be nice to know what part of libpulse has to be implemented to work properly with audio levels (or what is used inside xidlehook to detect audio)
In second case, there is two options: either to implement it through libpipewire, or to implement it through something that works with both pulse and with pipewire through libpulse (which is implemented in pipewire through pipewire-pulse).

Either way, it would be nice to have such support.

Would be nice if someone who uses pipewire could implement a new module. The pulse module should be a useful template for how it could work

It seems that pipewire now supports this correctly and while audio is playing caffeine activates automatically

@Meister1593
But does it work for you with xidlehook as well now or just caffeine?
Since I switched to pipewire (I do not know if it does matter that I am using pipewire-pulse) --not-when-audio is unfortunately not working anymore.

@Meister1593 But does it work for you with xidlehook as well now or just caffeine? Since I switched to pipewire (I do not know if it does matter that I am using pipewire-pulse) --not-when-audio is unfortunately not working anymore.

a lot of stuff happened in a while and unfortunately author of this tool passed away
i don't use xidlehook anymore (i use just gnome instead of setup i had) and if you're willing to use it, be mindful that it's unmaintained now

Thank you. I just read the text from Jackpot51 about it. That is sad.

Very sad to hear about jD91mZM2 😢

For those who want to keep using xidlehook and are still struggling with pipewire support, I found a workaround that is not the most elegant solution but works for me.

xidlehook has a cool feature that allows you to use sockets to communicate (see https://github.com/jD91mZM2/xidlehook#socket-api), so you can manually reset the timer at any given time (sending a message to the same socket you're using for idle detection).

If you run xidlehook like so:

xidlehook --socket /tmp/xidlehook.sock --not-when-audio --timer 600 "$HOME/bin/lock-screen" "" &

... then you could reset the timer checking for running sinks manually:

#
# Abort if there are any kind of sinks running (music audio, meetings, etc.)
#
echo "Checking running sinks..."

RUNNING_SINKS=$(pactl list short sinks | grep -c RUNNING)
if [ $RUNNING_SINKS -gt 0 ]; then
    echo "There are $RUNNING_SINKS running sinks. Aborting lock screen."
    xidlehook-client --socket /tmp/xidlehook.sock reset-idle
else
    echo "No running sinks. Locking screen..."    
    # lock screen using i3lock or whatever program you would normally use 
fi

The important piece here is the use of --socket when running xidlehook