iKK
iKK

Reputation: 7012

alfred script that "waits until key pressed..."

I try to write a /bin/bash Script in alfred and that Script shall pause at one point - and continue when the user presses a keyboard-key (or other shortcut).

I tried the following bash-cmd (see below) that starts a process and then on the second line tries to suspend the same process. But, unfortunately, the script simply continues without suspending !

/usr/local/bin/myProcessName $arg0

pkill -STOP -nf '/?(bash|sh)[ ]+(.*/)?'"myProcessName"'( |$)'

/usr/local/bin/myProcessName $arg1

The idea here was to give alfred another shortcut script that resumes the same process again, such as:

pkill -CONT -nf '/?(bash|sh)[ ]+(.*/)?'"myProcessName"'( |$)'

But again, the suspending did not work in the first place !

I also tried to give the full path to the process-name such as : (but no difference - there is no pause in the script !)

/usr/local/bin/myProcessName $arg0

pkill -STOP -nf '/?(bash|sh)[ ]+(.*/)?'"/usr/local/bin/myProcessName"'( |$)'

/usr/local/bin/myProcessName $arg1

How else can I give alfred the functionality I need (i..e calling an app with one argument, then let the user decide when the second argument shall be processed (i.e. by "press key to continue..." funtionality ???)

Upvotes: 0

Views: 218

Answers (1)

Jon
Jon

Reputation: 3671

I'm not sure if this is what you are after, but if you are trying to pass in two parameters, one after a delay, how about using named pipes?

If you create a named pipe

mknod /tmp/foo.pipe p

and use a script like this, call it stop.sh,

#!/bin/bash

arg1=$1
arg2=$(cat <foo.pipe)

echo $arg1 $arg2

you could run

bash stop.sh foo

then write the second parameter to the pipe from another shell or process

echo bar >>/tmp/foo.pipe

Until the second parameter is written to the pipe, the script will be blocked.

Upvotes: 1

Related Questions