Jump to content
joshnh

[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!

Share this post


Link to post

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.

Share this post


Link to post

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. 

Share this post


Link to post
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...

Share this post


Link to post

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. 

Share this post


Link to post
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

Share this post


Link to post

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.

 

Share this post


Link to post
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.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...