Skip to content
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

Support arbitrary script execution during countdown #44

pigmonkey opened this issue May 25, 2019 · 3 comments


Copy link

commented May 25, 2019

I would like the ability to play sounds at certain intervals during the countdown. Basically, I like the --voice option, but rather than actually calling voice_cmd I want to specify a different program.

I think the most flexible way to achieve this is to add a new argument to termdown that accepts the path to an executable script. During each iteration of the countdown loop, termdown can call this script and pass it seconds_left as an argument.

So executing termdown would look something like:

$ termdown -x ~/bin/ 60

Which will have the effect of termdown doing its normal 60 second countdown, plus on each second executing:

~/bin/ 60
~/bin/ 59
~/bin/ 58
~/bin/ 57

If I wanted to reimplement the current --voice behaviour, my ~/bin/ would look like:

case $1 in
        espeak "$1 seconds"
        espeak "$min minutes"

More realistically, I want a 10 minute timer that gives me a 60 second and 10 second audible warning that is more pleasant than espeak's voice. So my script would be:

case $1 in
        mpv ~/path/to/bell.mp3
        mpv ~/path/to/klaxon.mp3

It might be nice if termdown also informed the script if seconds_left <= critical, similar to how the voice support currently works.

Maybe it would be cleaner if termdown provided this information to the script as environment variables rather than as positional arguments? Such that termdown is executing:


This would also solve #42.


This comment has been minimized.

Copy link

commented Jun 4, 2019

Here's my attempt to this

Example usage:
python3 --exec-shell "espeak -v en-us" 10

the current second is put as the last positional argument, so the above would result to:

espeak -v en-us 10
espeak -v en-us 9
espeak -v en-us 8


This comment has been minimized.

Copy link

commented Jun 5, 2019

Yup, that's pretty much how I imagined it!

I think the only advantage to using environment variables is that, in the future, more context (like the critical seconds, or the value of some new flag that termdown was called with) can be passed to existing external scripts without breaking them. If those scripts depend on positional arguments, and termdown later changes the number or position of arguments it passes, it could break things for users.


This comment has been minimized.

Copy link

commented Jun 17, 2019

I've been using #45 for a bit now. It satisfies my use case, and I think greatly extends the capability of termdown. Is there any chance of getting something like this merged?

@trehn trehn closed this in #45 Jun 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.