Jump to content

alfredclough

Member
  • Content Count

    78
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by alfredclough

  1. Sorry about that--I updated the link.
  2. 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.
  3. 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.
  4. 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.
  5. 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}"
  6. 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?
  7. I had created a Bear workflow to automate a few things and this workflow adds some really helpful functionality. Thank you
  8. Playing around more with Script filter looks like it will work. I think I can capture the input plus set a variable for which option a user clicked so I should be able to do it all in one step.
  9. Right--My question is how I can capture an argument at the same time as giving the user three selections to choose between in one step.
  10. Here's what I want to do: User selects an option in a script filter. That passes them to a second step which is a list filter where they can make a choice and optionally enter a second argument. In my case what I want to do is let someone enter a search parameter in that second step. So the second step is a list filter that gives them three choices: search, search in a new window, search in a new tab and allows them to enter a search parameter. My problem is that anytime you enter an argument in a list filter it filters the options if that makes sense, but what I want to do is let someone enter a parameter that is passed along the workflow but have a choice of how to action that parameter. I realize I could easily do this by using modifiers (shift, fn, etc) but I'd rather make it more obvious by picking the option out from a list. I haven't created it yet or I would attach the workflow--I'm looking for input on how to do this.
  11. I tried that and I can build the JSON when I run the AppleScript in Apple's script editor, but when I tried to run it using Alfred, I get the message: execution error: System Events got an error: Can’t get path of file of application process "Safari" Here's the AppleScript I'm running: on run argv tell application "System Events" set runningProcesses to (every process whose background only is false) end tell set alfredJSON to "{\"items\": [" repeat with runningProcess in runningProcesses set appName to name of runningProcess set appPath to path of file of runningProcess set alfredJSON to alfredJSON & "{\"uid\": \"" & appName & "\", \"type\": \"default\", \"title\": \"" & appName & "\",\"subtitle\": \"\", \"arg\": \"" & appName & "\",\"autocomplete\": \"insert passage\", \"icon\": { \"type\": \"fileicon\", \"path\":\"" & appPath & "\" }}," end repeat set alfredJSON to alfredJSON & "]}" return alfredJSON end run Here's a link to the workflow. I'm using Alfred 3.6 and Mac OS 10.13.3
  12. I have a workflow where I want to provide a list of applications so that an application can be selected and the workflow continue. I want a list of the current running applications so I'm using a Script Filter. My question is how can I load the icon of the app to show it in the list rather than the icon of the workflow? I can't seem to find out how to programmatically load it. Here is the AppleScript I'm using with the Script Filter: on run argv tell application "System Events" set runningProcesses to (name of every process whose background only is false) end tell set alfredJSON to "{\"items\": [" repeat with appName in runningProcesses --set appName to name of runningProcess set alfredJSON to alfredJSON & "{\"uid\": \"" & appName & "\", \"type\": \"default\", \"title\": \"" & appName & "\",\"subtitle\": \"\", \"arg\": \"" & appName & "\",\"autocomplete\": \"insert passage\"}," end repeat set alfredJSON to alfredJSON & "]}" return alfredJSON end run
  13. I used NSPasteboard. For reference in case someone else lands here, here's what I used. The first option gets the html version of what's on the clipboard, the second version gets the text (how Alfred returns the clipboard in a workflow). In the first option, you could use other formats (rtf, etc) as per Apple's documentation. from AppKit import * # Get the current clipboard directly from Mac pb = NSPasteboard.generalPasteboard() # Check if we need html format from the clipboard if ulFormat == "html": cbDirect = pb.stringForType_("public.html") else: cbDirect = pb.stringForType_(NSStringPboardType)
  14. I tried a shell script first but I was running into problems with how it escaped markdown characters. Probably easy to fix, but to be honest it's been over a decade since I did any bash scripts so it wasn't obvious to me how to fix it. I solved it by doing a python script. In the process I discovered that Alfred seems to always use the plain text version of the clipboard in workflows, so I had to use Python to pull the clipboard directly if I wanted html that had been copied instead of just text. Regardless, Python solved the problem.
  15. Here's what I'm trying to do: I frequently capture information and store it in Ulysses for research on writing projects. I typically copy/paste it into Ulysses in the appropriate group. I created a workflow to automate this via Alfred. The workflow takes the contents of the clipboard and passes it to an Openurl to use Ulysses x-callback-url to add a new sheet. So far, so good. Frequently I copy/paste content that is online, and I want to keep the url of the content for later research. In order to automate this as much as possible, I used clipboard history. I copy the url, then copy the content, then insert it into Ulysses. In order to automate this completely, I modified my workflow so that it checks the chipboard history and if {clipboard:1} is a url, it combines that url with the content on the current clipboard and then passes it to Ulysses. I used an AppleScript to do this by storing the clipboard and previous item from clipboard history into a variable, loading those variables in AppleScript and then creating a new string. Here's the problem: when I do this something is wrong with the encoding of the string and I get strange characters in it. For example, apostrophes become Äô. Text passed through the workflow fine until I added this AppleScript. I don't know if the problem is when the AppleScript loads the variables using system attribute or if the problem is when it returns the string. I've included the AppleScript below to show what is does. Does anyone know how to get the AppleScript to encode the text properly? I tried using Run NSApplescript instead. It seems to properly encode the text, but the problem is that I cannot find a way to pass the clipboard contents since it doesn't read workflow variables and as far as I know, can't access the clipboard history. If an NSApplescript action could access the clipboard that would be an ideal solution. on run argv set theQuery to item 1 of argv set cbCurrent to (system attribute "cb_current") set cbPast to (system attribute "cb_past") set httpPrefix to "http" set newQuery to theQuery if cbPast starts with httpPrefix then set newQuery to theQuery & "\n" & "%% Source: " & cbPast & "\n" & cbCurrent else set newQuery to theQuery & "\n" & cbCurrent end if return newQuery end run
  16. I can see the usefulness, but right now it's not a big factor for me. The fact that searching groups searches the group tree enables me to drill down pretty quickly to child groups if that makes sense. There is one enhancement that would help me a bunch--the ability to open a sheet or a group in a new Ulysses window. I uses Ulysses for enough things that I frequently need to open something but not lose the sheet I have open already. I have a work around, but it would be great to have a modifier key or something that enabled opening a selected group or sheet in a new Ulysses window.
  17. Just want to say this workflow is amazing--it makes working with Ulysses so much more efficient.
  18. This feels like it should be simple, but can I create an Alfred workflow to add a keyboard shortcut for a menu item in an application. For example, in the same way you can go into System Preferences under App Shortcuts and you can create a keyboard shortcut for a specific application by giving it a menu item name, can you do the same in an Alfred workflow? I know this should be simple but I've done some searches and haven't found an example to do this.
  19. Sorry about that. Link has been updated.
  20. Sorry about that - I updated the link.
  21. Great catch. The linked file for the workflow has been updated.
  22. Sorry, I don't have Sierra so I'm not sure what the problem would be.
×
×
  • Create New...