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.