jerik Posted February 11, 2021 Share Posted February 11, 2021 (edited) Hi, I have a bash script "todo" which launches basically vim with my "journal.txt" file. When running the script form shell it works as expected. -> If a vim gui is running, i send a command to vim to call a function (which opens my journal.txt) -> If no vim gui is running, vim will be started with the call to the function as startup parameter. I can run the script repetitive within the shell and it works fine. I have setup a workflow with a hotkey and an assigned action with "run script" (/bin/bash). In the "run script" I call this "todo" script. When hitting the hotkey the first time, the script will be executed fine. # I see the execution of the script in my logfile When hitting the hotkey again (2), nothing happens. When hitting the hotkey again (3), nothing happens. When I now close vim. Vim will be opened again with the file "journal.txt". # I see the execution of the script in my logfile When I close vim again. Vim will be opened again with the file "journal.txt". # I see the execution of the script in my logfile Somehow Alfred seems to hold back the execution of the script, when I hit the hotkey, when the script is running already. How can I get rid of the holding back? The script shall be executed when the hotkey is triggered. The executed script "todo" #!/usr/bin/env bash set -o nounset set -o errexit # Normal log: write_log 0 message to show # Error log: write_log E message to show function write_log() { msgType="Info - " if test "$1" != "0"; then msgType="Error - " fi shift logMsg="$(basename $0): $msgType $@" logger $logMsg echo $logMsg } mvim=/usr/local/bin/mvim function run_vim() { if [ "$1" == 'o' ]; then func=Nextv2Todos else func=Journal fi write_log 0 run_vim with $func if [ $(/bin/ps aux | /usr/local/bin/rg -c \/Vim) -gt 1 ]; then # https://vi.stackexchange.com/a/318 $mvim --remote-send ":call ${func}()<cr>" write_log 0 remote-send else $mvim -c ":call ${func}()" write_log 0 normal call fi } # run: todo -c or todo -o while getopts "a:hvtoc-" options; do # a) a=$OPTARG;; case $options in o) run_vim $options; exit 1;; c) run_vim $options; exit 1;; h) usage; exit 1;; *) usage; exit 1;; esac done Here my workflow <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>bundleid</key> <string>com.alfredapp.jerik.journalhotkey</string> <key>category</key> <string>Productivity</string> <key>connections</key> <dict> <key>D0D170CF-42DF-4377-8032-B69D1C04AE97</key> <array> <dict> <key>destinationuid</key> <string>8B67BA2C-870A-4D05-B32A-EEBB5851DF6B</string> <key>modifiers</key> <integer>0</integer> <key>modifiersubtext</key> <string></string> <key>vitoclose</key> <false/> </dict> </array> </dict> <key>createdby</key> <string>jerik</string> <key>description</key> <string></string> <key>disabled</key> <false/> <key>name</key> <string>journal current</string> <key>objects</key> <array> <dict> <key>config</key> <dict> <key>action</key> <integer>0</integer> <key>argument</key> <integer>0</integer> <key>focusedappvariable</key> <false/> <key>focusedappvariablename</key> <string></string> <key>hotkey</key> <integer>38</integer> <key>hotmod</key> <integer>393216</integer> <key>hotstring</key> <string>J</string> <key>leftcursor</key> <false/> <key>modsmode</key> <integer>0</integer> <key>relatedAppsMode</key> <integer>0</integer> </dict> <key>type</key> <string>alfred.workflow.trigger.hotkey</string> <key>uid</key> <string>D0D170CF-42DF-4377-8032-B69D1C04AE97</string> <key>version</key> <integer>2</integer> </dict> <dict> <key>config</key> <dict> <key>concurrently</key> <false/> <key>escaping</key> <integer>102</integer> <key>script</key> <string>/Users/jerik/workspace/bins/sunix/todo -c</string> <key>scriptargtype</key> <integer>1</integer> <key>scriptfile</key> <string></string> <key>type</key> <integer>0</integer> </dict> <key>type</key> <string>alfred.workflow.action.script</string> <key>uid</key> <string>8B67BA2C-870A-4D05-B32A-EEBB5851DF6B</string> <key>version</key> <integer>2</integer> </dict> </array> <key>readme</key> <string></string> <key>uidata</key> <dict> <key>8B67BA2C-870A-4D05-B32A-EEBB5851DF6B</key> <dict> <key>xpos</key> <integer>400</integer> <key>ypos</key> <integer>50</integer> </dict> <key>D0D170CF-42DF-4377-8032-B69D1C04AE97</key> <dict> <key>xpos</key> <integer>50</integer> <key>ypos</key> <integer>50</integer> </dict> </dict> <key>variablesdontexport</key> <array/> <key>version</key> <string></string> <key>webaddress</key> <string></string> </dict> </plist> Edited February 11, 2021 by jerik Link to comment
vitor Posted February 12, 2021 Share Posted February 12, 2021 2 hours ago, jerik said: Here my workflow When asking for help with a Workflow, please upload it. We shouldn’t have to manually recreate it from a plist. 2 hours ago, jerik said: Somehow Alfred seems to hold back the execution of the script, when I hit the hotkey, when the script is running already. On the top right of your Run Script, you’ll read “running instances” which will be set to “Sequentially”. Change it to “Concurrently”. Link to comment
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