Jump to content

Output script not invoked


Recommended Posts

Hi,

 

I have a small workflow for pomodoro sessions. The idea is simple, a script filter sends either "start" or "stop" arg to an output script start or kill a running pomodoro timer. The "start" keyword works as expected, but "stop" never works. In debug window, I can see "stop" is indeeded sent, but somehow the script does not run. In command line, I can use whatever I have in the script to do exactly expected.

 

Is there anything wrong with my scripts, or anything with my understanding of alfred's messaging mechanism?

 

github link: https://github.com/roylez/alfred_pomodoro

 

Thank you~

Link to comment

Hi,

 

I have a small workflow for pomodoro sessions. The idea is simple, a script filter sends either "start" or "stop" arg to an output script start or kill a running pomodoro timer. The "start" keyword works as expected, but "stop" never works. In debug window, I can see "stop" is indeeded sent, but somehow the script does not run. In command line, I can use whatever I have in the script to do exactly expected.

 

Is there anything wrong with my scripts, or anything with my understanding of alfred's messaging mechanism?

 

github link: https://github.com/roylez/alfred_pomodoro

 

Thank you~

 

Hi there, could you please fill in your Powerpack email address in your forum profile before asking Powerpack-related questions? Once you've confirmed your Powerpack status, we'll be happy to lend a hand :)

 

Cheers,

Vero

Link to comment

Is there anything wrong with my scripts, or anything with my understanding of alfred's messaging mechanism?

 

The script is wired up so should run, my guess is it's the escaping options causing the issue... try changing the bash escaping for both to:

 

bash%20escaping.png

 

Let me know how you get on :)

Link to comment

It does work from terminal. Below is what I get in debugger. It looks like the message is sent to output script and notification, but the script does not run. Moving the script from output layer to action, the problem persists.

  </item>
</items>
[INFO: alfred.workflow.input.scriptfilter] Processing output 'alfred.workflow.output.notification' with arg 'stop 7086'
[INFO: alfred.workflow.input.scriptfilter] Processing output 'alfred.workflow.output.script' with arg 'stop 7086'

It is fair simple to reproduce.

 

  1. In Alfred, run "pmd start xxxx"
  2. Type "pmd", and the first option item will list current running session, select it, and a "stop" arg will be sent to the output script ( to invoke "ruby ./pomodoro.rb stop" )
  3. In terminal, "ps -ef |grep pomodoro" will tell if a "ruby ./pomodoro.rb start xxxx" is still running. If it is, then the script in step #2 is not invoked. Typing "ruby ./pomodoro.rb stop" in terminal will kill the session aforementioned.
Link to comment

I'm pretty certain the reason Alfred isn't running your "stop" script is because it's still running the "start" one. Alfred won't run one of its actions if it's still running from a previous call. ruby pomodoro.rb start XXXX doesn't exit for several minutes, and Alfred won't run the same Run Script action again until it does, so you can never run "stop" while the pomodoro is still running…
 
If you change your Run Script to the following:
 

ruby ./pomodoro.rb {query} 2>&1 &

 
to move the process to the background, Alfred's Run Script action should complete immediately and your "stop" command will work.
 
That said, the script appears to have a bug: It kills running processes, but it doesn't remove the PID from the history, so the workflow shows them as still running, even when they're not.

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...