Jump to content

alfredclough

Member
  • Posts

    94
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by alfredclough

  1. I'm very confused - I updated the code but now the workflow seems to only half work. The X and width coordinates are set properly, but the Y ones are not. And when I try to debug the alfred debugger says that nothing is being returned by the script. 🤔
  2. Thank you so muich. The reason to go through all that trouble is I want the ability to put a margin or space between windows. So this allows me to adjust the windows with margin around them. I could not see a way to do that with the preset task. In my case I can choose 1/2 screen but the workflow has a variable for margin that leaves a bit of border around the window.
  3. Here's a link to the workflow: https://web.tresorit.com/l/fw0DE#qF-3oQJjPhobwKyyYX1iqA
  4. I'm trying to make sure I am not missing something obvious, but I'm not getting the expected result. I have a script option that, for example, outputs the following: "{ \"alfredworkflow\" : { \"variables\" : { \"new_x\" : 10, \"new_y\" : 100, \"new_width\" : 835, \"new_height\" : 1097 } } }" Then I have an automation task that looks like the attached. However the window is not moved properly as if the variables are not resolving correctly. If I hard code the values instead of using the variables then the window does move correctly. I cannot figure out what is wrong here.
  5. I'm trying to dynamically set the X Origin, Y Origin, etc in a Set Custom Window Bounds automation task but I cannot figure out how to pass in the variables. Do I need to use environment variables or can I set it all in JSON similar to this: https://www.alfredforum.com/topic/18701-dynamic-input-for-automation-tasks/?_fromLogin=1 ? If this can be set by JSON where do I find the config variable information necessary to set the variables?
  6. If this was a workflow to be shared, I'd agree. In my case, whenever I updated python3 on my machine it will automatically update the path in my .bash_profile so I'll never need to update the Alfred workflow. The only other option is having to update the workflow every time I update python. that's not horrible, but it is an extra step. And my .bash_profile only includes the PATH configuration so loading it doesn't affect performance. So I'm not sure how any other solution would be better in this case. And it will work on all my machines because they will all have the PATH setting updated when Python3 is installed or updated. But if the workflow was going to be shared that is completely different. In that case I would have written it in python2.
  7. In case it helps anyone else, in my case I ended up solving it by adding this line to the shell script that runs the python script: source ~/.bash_profile This sets the path to the default shell path. This way the script will automatically update the path is uses to search for python3 with future updates and I don't have to hardcode a full path to the specific version of python. Now it runs without any issues.
  8. Well I assumed the shell script would create a shell and setup the variables properly which is why I used that vs. calling the python script directly. Here is a link to the workflow: https://www.dropbox.com/s/uai25vc4vxqvnxt/Test Workflow.alfredworkflow?dl=0
  9. l'm really confused. I created a file filter workflow that calls a script file that then calls a python script. I can run the script from the command line with no problems at all. When I try to run the Alfred workflow I get a pop up that says the python3 command requires the command line developer tools (see the attached image). Why am I getting this message when the script runs perfectly fine outside of Alfred?
  10. Alfred appears to block it so I'm checking if there is a way.
  11. The title says it all. I have a keyword that triggers a snippet when it is typed and would love to have it trigger a workflow where I can send some custom keystrokes. Is that possible? Or can I insert keystrokes into a snippet (I'm guessing not since it is text).
  12. Setting up a new computer and want to sync my Alfred preferences. I've always use the Apps folder and yes I know about the restriction. In the past this always fixed it: defaults write com.runningwithcrayons.Alfred-Preferences-3 dropbox.allowappsfolder -bool TRUE However it is not working on the new machine. I even tried changing the above to Preferences-4 and it still did not work. My other machine is still synching fine. Any idea what I need to do on the new machine to allow Alfred to load my synced preferences from the Apps folder?
  13. Thanks! That fixed it. Hmm. I wonder why it worked for years 🤔
  14. Every since I've upgraded to Catalina I have a workflow that is throwing an error but I cannot figure out why. It is a script folder that searches file in a folder. Here is the error: [08:11:59.413] Logging Started... [08:12:03.783] Recent Downloads[Script Filter] Queuing argument '' [08:12:04.065] Recent Downloads[Script Filter] Script with argv '(null)' finished [08:12:04.069] Recent Downloads[Script Filter] Warning: Use of undefined constant BASE_DIR - assumed 'BASE_DIR' (this will throw an Error in a future version of PHP) in Command line code on line 1 Warning: Use of undefined constant FILE_PATTERN - assumed 'FILE_PATTERN' (this will throw an Error in a future version of PHP) in Command line code on line 8 Here is the code for the script filter: define(BASE_DIR, getenv('HOME') . '/Downloads'); $file_pattern = "{query}"; if ( $file_pattern ) { $file_pattern = trim($file_pattern); $file_pattern = preg_quote($file_pattern); $file_pattern = '/' . str_replace(' ', '.', $file_pattern) . '/i'; } define(FILE_PATTERN, $file_pattern); $dir_contents = scandir(BASE_DIR); $files = array(); foreach ( $dir_contents as $file ) { $files[$file] = filemtime(BASE_DIR . '/' . $file); } arsort($files, SORT_NUMERIC); //filter out non matching files if ( $file_pattern ) { foreach ( $files as $file => $modtime ) { if ( ! preg_match(FILE_PATTERN, $file) ) { unset($files[$file]); } } } $items = new SimpleXMLElement("<items></items>"); if ( count($files) == 0 ) { $c = $items->addChild('item'); $c->addAttribute('arg', 'No Match'); $c->addAttribute('valid', 'no'); $c->arg = 'No Match'; $c->addAttribute('type', 'file'); $c->title = 'No Match'; $c->subtitle = ''; $c->icon = 'icon.png'; $c->icon->addAttribute('type', 'default'); } foreach( $files as $basename => $modtime ) { $fullpath = BASE_DIR . '/' . $basename; if ( substr($basename, 0, 1) != '.' ) { $c = $items->addChild( 'item' ); $c->addAttribute('arg', $fullpath); $c->arg = $fullpath; $c->addAttribute('type', 'file'); $c->title = $basename; $c->subtitle = $fullpath; $c->icon = $fullpath; $c->icon->addAttribute('type', 'fileicon'); } } echo $items->asXML(); I can't quite figure out what went wrong? I've used this for a long time however if there is an easier way to do this I'm also open for ideas.
  15. Sorry about that--I updated the link.
  16. To make a long story short, I updated a workflow. It has a long action that is done by an Alfred Script object in AppleScript. In certain cases, I want to do some of the work via a python script rather than in AppleScript. To do this I added the following which checks a variable already set and if so tries to run a python script I put in the workflow folder. (The argument passed is encapsulated in quotes) --check if online and if so, use Python. if contents of online is "online" then --run script to put passage onto the clipboard do shell script "python ./get_verse.py \"" + passageRef + "\"" --paste the passage into the current app keystroke "v" using command down else The réponse I'm getting back in Alfred debugging is: [2019-01-16 15:18:30][ERROR: action.script] /Users/samuel/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/27C48708-2D1A-4008-BCBF-CCABCD6247DC:801:811: execution error: Can’t make "python ./get_verse.py \"" into type number. (-1700) This tells me it's not executing the python script. I'm sure there's something simple here I'm missing but cannot figure out what it is.
  17. Thank you! It's a solution I found that seemed to work reasonable quickly. If there's a better option I'm open to it.
  18. I have a strange problem I am trying to solve. I must be missing something because this should be quite simple. I have a script to check and see if the computer is online. Here is the script: echo -e "GET http://google.com HTTP/1.0\n\n" | nc google.com 80 > /dev/null 2>&1 if [ $? -eq 0 ]; then echo "online" else echo "offline" fi After this I have two filters. One filter checks if the value is online and the other checks if the value is offline. The problem is when I run the workflow it always stops at the filter and does not continue. I ran Alfred in debut and here is what I see: [2019-01-10 07:38:49][action.script] Processing output of 'utility.filter' with arg 'online ' [2019-01-10 07:38:49][action.script] Processing output of 'utility.filter' with arg 'online ' It appears to me that there is an extra new line after "online" which would explain why the filter is not successfully completing. However, I cannot see any reason why an extra new line would be inserted? This seems like it should be something very simple so I must be missing something but I cannot see what it is.
  19. I found the bug fix for tags with spaces. In the script that is run by the Bear Search Tag trigger to open Bear, the first line of the script is: orig_query={query} It needs to be changed to enclose {query} in quotes otherwise any tag with spaces in it will fail. Here is what the corrected line should be: orig_query="{query}"
  20. I'm not sure if anyone else has run into this, but it seems like the ability to open a tag in bear does not work if a tag has spaces in it. I'm guessing something's not getting encoded properly somewhere?
  21. I had created a Bear workflow to automate a few things and this workflow adds some really helpful functionality. Thank you
×
×
  • Create New...