-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] generic --not-when flag #41
Comments
You could always compose your own xidlehook application consisting of the conditions you want, using xidlehook-core. Though, if you just want to run a bash command you could just do |
Thanks for the reply! The differences I see between your proposed workaround and the request are (1) it applies only to one timer, and (2) it moves to the next timer in the chain even if the check fails, which is not the behaviour of the On a related note to (1), the ability to apply #! /usr/bin/env bash
suspend_hook() {
xidlehook --not-when-audio --timer 300 'systemctl suspend' ''
}
export -f suspend_hook
xidlehook --timer 300 'xscreensaver-command -activate' '' \
--timer 0 suspend_hook '' But I imagine it would be nicer to write the above like so: xidlehook --timer 300 'xscreensaver-command -activate' '' \
--timer 300 'systemctl suspend' '' --not-when-audio I am curious about Rust, but haven't touched it yet! Implementing my own client might be a good challenge for me though! I'll take a look at xidlehook-core :) To summarize, I think two improvements could be made to the command syntax -
I actually can't come up with a reasonable workaround for the first suggestion - I think it would involve process management and nested xidlehooks. |
I can see the value in having But I am very uncertain about having some kind of generic Keep in mind that xidlehook isn't meant for ease of usage, since you're supposed to just start it in some shell script somewhere rather than run it and have it read some config files. There shall be no |
Gotcha. I understand the desire to keep things minimal. (: FWIW, I think this bash script achieves the desired functionality #! /usr/bin/env bash
youtube_is_running() {
# custom stuff here
return 1
}
pid=
while true; do
if ! youtube_is_running; then
if [ -z $pid ]; then
xidlehook --timer 5 'xscreensaver-command -activate' '' &
pid=$!
fi
elif [ ! -z $pid ]; then
kill $pid
pid=
fi
sleep 1
done |
@Jameh Does something like this work instead? I'm trying to avoid as many spinloops as possible :) Pretend this script lives as #! /usr/bin/env bash
youtube_is_running() {
# custom stuff here
return 1
}
IFS='' read -r -d '' TIMER_COMMAND <<EOF
if youtube_is_running; then
# YouTube is running, exit xidlehook for now
respawn_task() {
# Do a spin loop waiting for YouTube to exit
while youtube_is_running; do
sleep 1 # or whatever delay/trigger you want
done
# Restart xidlehook
exec /my/script/path/here.sh
}
# Launch task and exit xidlehook
respawn_task &
pkill $PPID
fi
EOF
exec xidlehook --timer 5 "$LOCKER_COMMAND" '' |
What if a timer that exits >0 causes all subsequent timers to not run? That would mean we could use this proposed workaround. I don't know if this would be "pure", but this solution or custom |
It would be nice if we could have a generic
--not-when
flag that takes a script as an argument and runs the timer conditionally on its exit code. e.g.and we could write our own checking scripts for
youtube
, etc.The text was updated successfully, but these errors were encountered: