roylez Posted February 25, 2015 Posted February 25, 2015 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~
Vero Posted February 25, 2015 Posted February 25, 2015 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
Andrew Posted February 26, 2015 Posted February 26, 2015 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: Let me know how you get on
roylez Posted February 27, 2015 Author Posted February 27, 2015 (edited) Hi Andrew, I have tried your suggestion but still no luck. By the way, there is no such option "run instances of this script: sequentially" here, but I do not think this would make any difference. Edited February 27, 2015 by roylez
deanishe Posted February 27, 2015 Posted February 27, 2015 Andrew will be using a beta of the next version. Don't worry about his extra settings. What does the debugger say when you run your script? Does it work from Terminal?
roylez Posted February 28, 2015 Author Posted February 28, 2015 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. In Alfred, run "pmd start xxxx" 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" ) 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.
deanishe Posted March 1, 2015 Posted March 1, 2015 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.
roylez Posted March 3, 2015 Author Posted March 3, 2015 The PID part can be easily fixed. But I tried putting the script into background, "stop" command still does not work.
deanishe Posted March 3, 2015 Posted March 3, 2015 It successfully killed the pomodoro.rb process during my tests.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now