Jump to content

Way to sort keyword trigger matches before matched Applications (Default Results)?


Recommended Posts

12 hours ago, luckman212 said:

I'm currently playing with osxmetadata and it's pretty robust.

 

Thank you, but that makes it a no-go for me. I go to great lengths to avoid external dependencies, especially Python ones as those are the ones that always crap themselves when I need them.

 

12 hours ago, luckman212 said:

It's Python, so fits nicely within an Alfred workflow

 

That’s a common sentiment, and I never understood it. There’s nothing about Python that makes it particularly suited for Workflows over Bash or any other language that ships with macOS. I would even argue Python is the worse choice because it’s stuck at an old version.

 

Still, thank you for the recommendation and I appreciate you taking the time to write the examples. They may be useful to someone else.

 

13 hours ago, Mr Pennyworth said:

I use this command

 

Thank you. Simpler than I though; I should’ve checked the Finder’s AppleScript dictionary. I’ll see if I can make it into JXA.

 

Did any of you try the Spotlight Privacy panel route and decided it didn’t work / was too much trouble, or did you start with the comment solution?

 

4 hours ago, Andrew said:

I'll add this to my list, but am aware that it may also cause some undesirable behaviour... for example, if a user doesn't want a valid:false item to ever have any significance, and all of a sudden it's been promoted to the top, this isn't good.

 

I’d be fine with a non-standard solution to say “send this result straight up on every match” (so on “o”, “oc”, and “ocr”, using the case in this thread), which would tell it to latch that time and leave everything else the same.

Link to comment
10 hours ago, vitor said:

Did any of you try the Spotlight Privacy panel route and decided it didn’t work / was too much trouble, or did you start with the comment solution?

I started with the comment solution because I wanted to use spotlight as a junk drawer.

 

10 hours ago, vitor said:

I’ll see if I can make it into JXA.

Have you written your process down somewhere?
Would love to read a detailed "how to convert applescript to JXA" :)

Link to comment
15 hours ago, vitor said:

I would even argue Python is the worse choice because it’s stuck at an old version.

 

Python 3.8 is installed on Catalina. 3.9 is the latest version.

 

15 hours ago, vitor said:

There’s nothing about Python that makes it particularly suited for Workflows over Bash or any other language that ships with macOS

 

JSON support alone makes it much better suited for workflows than bash (or AppleScript).

Link to comment
13 hours ago, Mr Pennyworth said:

Have you written your process down somewhere?
Would love to read a detailed "how to convert applescript to JXA" :)

 

Typically it’s a matter of reading both dictionaries and making some deductions, as it’s not necessarily straightforward and will require some poking around. The closest I have to an example is grabbing the URL and title of browsers in both AppleScript and JXA.


And in Alfred

tell application id "com.runningwithcrayons.Alfred" to run trigger "TRIGGER" in workflow "WORKFLOW ID" with argument "ARGUMENT"


Becomes

Application('com.runningwithcrayons.Alfred').runTrigger('TRIGGER', { inWorkflow: 'WORKFLOW ID', withArgument: 'ARGUMENT' })


So you can see the similarities, but the conversion isn’t obvious just by looking at the original AppleScript.


In this case, I’m unsure. It’s simple to add a comment to a selection in the Finder

Application("Finder").selection()[0].comment = "alfred:ignore"


But I’m not yet sure how to do it to a given path, if it’s even possible.

 

7 hours ago, deanishe said:

Python 3.8 is installed on Catalina.

 

I stand corrected on that point. I’ve recently seen threads where python 3 was being used on a Workflow and that seemed to be an issue, hence my comment.

 

7 hours ago, deanishe said:

JSON support alone makes it much better suited for workflows than bash (or AppleScript).

 

In specific cases—like using a Script Filter—which aren’t a given. Even then you could use jq or another for JSON support, which is the missing piece. Yes, that uses an external dependency, but so did the post I was replying to. Bash itself is a glue language, so that composability with external tools is expected and encouraged.


Point being, Bash and AppleScript are languages less suited for Workflows only in the sense that they’re less suited for self-contained modern programs in general. There’s nothing intrinsically about Python (extrinsically, there’s your library) which makes it a superior language for Workflows.

 

However, I now see the original post only claimed Python was a good fit, not that it was a better fit, so I chose the wrong place to make that point.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...