Jump to content

duplex143

Member
  • Posts

    7
  • Joined

  • Last visited

duplex143's Achievements

Helping Hand

Helping Hand (3/5)

2

Reputation

  1. Excuse me for asking too many questions. How do you kill child processes you create when you choose Terminate previous script in alfred's run behaviour ? User enters input hello and you start a background process. Before it's completed, user types world. Now alfred terminates the previous process. How do you kill the child process you created earlier? If you terminate it, you'd do some graceful termination in your code. But if alfred terminates, what happens?
  2. Nvm. Found your github repo (https://github.com/deanishe/alfred-workflow/blob/master/workflow/background.py). I'll go thru this and figure out myself. Didn't expect I was getting help from special forces!
  3. Ok understood. Can you please share such workflows.
  4. Thanks @deanishe I've looked into rerun and variables/state variables. I'm trying to achieve this. When user enters keyword, show them the defaults & start a script in the background(https://unix.stackexchange.com/a/130902/291926). The script makes some network calls and when we have the output of the network call, I'd like to display those results. Basically, I'm unable to replicate the wait feature. This is my script in alfred. TIMER=$((timer)); #default value will be 0 if [[ $TIMER -le 1 ]] # TIMER<=1 then if [[ $TIMER -eq 0 ]] # TIMER==0 then {./test.sh}& fi cat << EOB { "rerun" : 1, "variables": { "timer": 1 }, "items": [ { "title": "Default title", "subtitle": "Default subtitle" } ]} EOB fi This is my test.sh #!/bin/bash sleep 5 cat << EOB { "variables": { "timer": 4 //Any variable other than 0 or 1 is fine }, "items": [ { "title": "Fetched title", "subtitle": "Fetched subtitle" } ]} EOB Also, alfred isn't supporting bash's background multi-processing. Alfred is waiting at this line {./test.sh}& instead of making it run in background. Please let me know if you have any ideas.
  5. This is asked way back in 2013 and I see no relevant solution/help for this.
  6. How do I return multiple items as output of a script filter? Upon execution of the script, I'd like to output something immediately. After let's say 5 sec/successful network call, I'd like to append some more results. I'm trying to run something like this: This is what's happening: After 5 sec, I see Desktop in alfred search results. This is what's I'm expecting to happen: Desktop should be appearing immediately in alfred search results. After 5 sec, Downloads should appear below Desktop. import time xml1=""" <?xml version="1.0"?> <items> <item uid="desktop" arg="~/Desktop" valid="YES" autocomplete="Desktop" type="file"> <title>Desktop</title> <subtitle>~/Desktop</subtitle> <icon type="fileicon">~/Desktop</icon> </item> </items> """ print(xml1) time.sleep(5) xml2 = """ <?xml version="1.0"?> <items> <item uid="downloads" arg="~/Downloads" valid="YES" autocomplete="Downloads" type="file"> <title>Downloads</title> <subtitle>~/Downloads</subtitle> <icon type="fileicon">~/Downloads</icon> </item> </items> """ print(xml2)
×
×
  • Create New...