Jump to content

[HELP] Need to loop through a workflow until stop command is issued


Recommended Posts

New to creating workflows from scratch, have only really tweaked existing workflows.

 

I need to set up a timer that loops indefinitely once set, with the ability to stop it at any time. What's the best way to do this?

 

All help appreciated. Thanks!

Link to comment

My thinking so far has been to begin the core of the workflow with an external trigger that is started when using a keyword input. The workflow then runs once (with a delay set during the workflow), checks that the variable "continue" is still set to "yes", and if it is the workflow ends by calling the same external trigger that starts it, triggering the loop. I then have a separate keyword input to set the "continue" variable as "no", so that when the loop next gets to the filter it doesn't continue, but it's not stopping the loop as hoped.

Link to comment

It sounds like Alfred considers those to be two separate workflow processes.

 

The way I'd do it is with a script that loops. It would delete a "stop" file on start up, then check every second to see if it exists. If it does, the script exits (possibly deleting the "stop" file).

 

Your stop command would create the "stop" file.

 

You could also write the looping script's PID to a file, then read it and kill the process with your stop command. 

Link to comment
Just now, deanishe said:

It sounds like Alfred considers those to be two separate workflow processes.

 

The way I'd do it is with a script that loops. It would delete a "stop" file on start up, then check every second to see if it exists. If it does, the script exits (possibly deleting the "stop" file).

 

Your stop command would create the "stop" file.

 

You could also write the looping script's PID to a file, then read it and kill the process with your stop command. 

 

Scripting is out of my realm, and I was hoping it would be a relatively simple thing to accomplish, but perhaps not...

Link to comment

It's very simple as far as scripts go. A few lines. 

 

I'll happily write it for you, but you'll have to tell me what you're actually trying to do: the workflow as you've described it doesn't actually do anything. It just starts then stops. 

Link to comment
2 minutes ago, deanishe said:

It's very simple as far as scripts go. A few lines. 

 

I'll happily write it for you, but you'll have to tell me what you're actually trying to do: the workflow as you've described it doesn't actually do anything. It just starts then stops. 

 

That would be awesome!

 

I need a notification with a tone to occur every 5 min. This needs to keep repeating until I stop it.

 

I'd be more than capable of making adjustments as necessary once I saw how the script was written.

Edited by joshnh
Link to comment

I've built a simple workflow.

 

There are start and stop keywords to, well, start and stop the script.

 

The actual script, ticker.py, is inside the workflow folder. Right-click the workflow in Alfred Preferences and choose "Open in Finder" to see it.

 

By default, the script calls the workflow's notify External Trigger every 300 seconds (5 minutes). I've connected that to a Play Sound action, but you can connect it to any kind of action (or multiple actions).

 

You can change the interval by adjusting the INTERVAL setting in the workflow's configuration sheet by clicking the [?] icon. The value is in seconds.

 

Link to comment
10 minutes ago, deanishe said:

I've built a simple workflow.

 

There are start and stop keywords to, well, start and stop the script.

 

The actual script, ticker.py, is inside the workflow folder. Right-click the workflow in Alfred Preferences and choose "Open in Finder" to see it.

 

By default, the script calls the workflow's notify External Trigger every 300 seconds (5 minutes). I've connected that to a Play Sound action, but you can connect it to any kind of action (or multiple actions).

 

You can change the interval by adjusting the INTERVAL setting in the workflow's configuration sheet by clicking the [?] icon. The value is in seconds.

 

I've never written python, but I understand the logic behind it. Thank you so much for taking your time to do this. It's greatly appreciated.

Link to comment
  • 6 years later...

@deanishe You built this simple workflow way back in 2017 with Alfred 3. I've only tried using it today but I can't seem to get it to work. I changed the Alfred Version number in the python script, but it still doesn't seem to be talking. Are you able to update that simple "Ticker / Start / Stop" workflow so it works in 2024 with Alfred 5, please? I'd love to have something like this to automate a process until I tell it to stop.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...