Jump to content

Jasondm007

Member
  • Posts

    342
  • Joined

  • Last visited

  • Days Won

    11

Posts posted by Jasondm007

  1. For illustrative purposes, in case the description above wasn't clear, here's a straightforward example with the Alfred 5.app (where tag=red). Even with the recursive option selected, the tags automation tasks shouldn't be tagging the internal contents of applications, right (i.e., Alfred should know not to tag the internal contents of packages, like applications)?

     

    image.thumb.png.0aa0534d8fcd6e9ff7a81dff0a531746.png

     

    image.thumb.png.14ab31f1a3ba5e59188f5e027c5b36f5.png

     

    PS - I didn't tag the actual Alfred 5 app, in my applications folder. I just dragged this one over to my desktop to illustrate the point.

  2. On 10/9/2015 at 3:13 PM, Andrew said:

    It should work with applications, you just need to reload the cache with the 'reload' keyword after setting the ignore tag/comment on the apps as for performance, the cache doesn't always re-check metadata unless necessary.

     

    @Andrew & @deanishe - Is there any downside to tagging applications (e.g., with "alfred:ignore")? Since Apple's default apps all require changing their permissions to add a tag or comment to them, I wasn't sure if this was something that could cause problems down the road. For instance, I'd love to add the "alfred:ignore" tab to applications like the "Migration Assistant" or "Audio MIDI Setup", which I don't exactly need to see in Alfred's results, given how little I use them. Thanks!

  3. @vitor Thanks a ton for the thoughtful and detailed response above. This is super helpful!

     

    I hate to admit it, but I didn't realize that it was even possible to edit the executable. I'll take a look at everything, and see if I can figure out which constants need to be modified when using multiple scripts in a workflow (to avoid overwriting things, etc.).

     

    Thanks a ton! I'm looking forward to tinkering with this one (and ... think Notificator should have been included in Alfred 5 ;)

  4. On 12/20/2017 at 11:24 AM, vitor said:

    Regarding notificator, you only run the setup once: to solidify an icon and a bundle ID. It’ll save it to an app. You keep that app inside the Workflow’s directory and call it as needed. It will work on all your Macs when you share/sync the Workflow amongst them.


    You cannot set your own icon with Alfred’s notification; if you could, notificator would not exist. A notification needs to use the icon of the app that calls it.

     

    Hi @vitor - I recently came across your Notificator app, and it looks awesome! I had been looking for a cleaner way of handling workflow notifications, and your app looks like it will do a great job.

     

    To that end, I have a couple of minor questions that I was hoping to bounce off you, regarding its use:

     

    1 - Is it possible for the Notificator to use different icons/images from a workflow (assuming this is even possible in MacOS - i.e., that apps' notifications can display different icons from their defaults)?

     

    I didn't see an option in the command where users could tell the app which icon to use (like a file path or name to an image inside the workflow's directory), but I thought I'd ask. From what I understand, the first time you call the app, it automatically pulls its icon from the default one in the workflow. Then, once the app is built, it will only use that specific icon (i.e., unless you rebuild it, and the workflow's default icon is different at the time that it's rebuilt). 

     

    2 - Assuming that's correct, is it possible to add more than one Notificator to a workflow, and assign each a different icon?

     

    In other words, if each Notificator app always has to display the same icon, could you get around this limitation by simply adding more than one of them to the workflow? Obviously, this would require there to be some way for users to tell the Notificator, when it's first built, which icon/image for it to use (i.e., otherwise, even if you could add more than one to a workflow, they would both pull the workflow's default icon when built - defeating the purpose of having more than one in a workflow).

     

    3 - Is it possible for users to specify a different app name for the Notificator (i.e., on setup or something, so that you see that name instead of "Notificator" in System Preferences > Notifications & Focus > Notifications)?

     

    Sorry for all of the questions @vitor. Regardless, the Notificator looks amazing! You rock!!!

  5. While this isn't strictly speaking a bug, I don't think when people select the "Recursive" option to "Act on directory contents" for the Automation Tasks of tags (e.g., Add Tags, Remove Tags, Clear Tags) that they intend this to apply to the contents of packages.

     

    For instance, if you use the "Add Tags" Automation Task, and select the "Recursive" option, when it's applied to an application, it will actually add the tag to the invisible contents of the application, too - which could cause problems, and seems like overkill.

     

    I'm sure there are a bunch of ways to fix this, but it'd probably be easiest to do a quick content tree check for "com.apple.package" - which is broad enough to catch applications, bundles, kernel extensions and most things you wouldn't want Alfred thumbing through - and to only apply/remove/clear the tags of children of files that don't contain it. In other words, if it's a package, Alfred should just behave as if the user had not selected the recursive option (i.e., applying/removing/clearing the tags of the package but NOT its children/contents).

     

    If you need any more info, just let me know. Cheers!

     

    PS: I'm on Tasks Version 2022.14 (Last Checked Sep 13, 2022, 4:06 PM) & Alfred 5.0.2

  6. 1 hour ago, vitor said:

    Nice share @Jasondm007. Do you have the workflow published somewhere to receive contributions? The code can be shorter, some of the lines aren’t doing anything:

     

    use framework "Foundation"
    
    on run argv
      set theQuery to argv as string
      set pb to current application's NSPasteboard's pasteboardWithUniqueName()
      pb's clearContents()
      pb's writeObjects:{theQuery}
      set theResult to current application's NSPerformService("SEARCH_WITH_SPOTLIGHT", pb)
    end run

     

     

    Thanks for cleaning it up, @vitor!!

     

    As for contributions, hopefully, others who find it helpful will just pay it forward. I've learned so much from this forum - especially from you, @deanishe, @GuiB, & @Andrew - that I'm happy to help where I can.

     

    I should have noted this before, but for others who come across this post down the road, you can use the same approach to kick off other text-based services on your mac. Just substitute the "SEARCH_WITH_SPOTLIGHT" bit in the code above with your intended service (e.g., "Search With Google", "Look Up in Dictionary", etc.). However, sometimes it takes a little trial and error - as you may need to dig through the service's Info.plist file to find the appropriate key. For instance, in this case, you can't just use "Spotlight", you have to use "SEARCH_WITH_SPOTLIGHT".

     

    FWIW: The "Jump to" option in the "Action in Alfred" action, really ought to contain all of Alfred's default actions. While the feature did not exist at the time of @s95hc8 original post, adding it would eliminate the need for this AppleScript altogether (i.e., people could just attach a fallback or anything else directly to the "Search with Finder" universal action). 

  7. On 9/14/2022 at 10:19 AM, Jasondm007 said:

    @GuiB or @deanishe - By chance, do you guys know if there's a way to get Alfred to wait for a modifier release to occur when used with keywords (or script filters, for that matter)? In other words, is there a way to achieve what Alfred is doing with its hotkey trigger behavior (pictured above - wherein it will wait to kick things off until the keys are released), when configuring the connection from a keyword or script filter that's run via action modifier?

     

    I have a couple of GUI-based workflows for handling things that aren't scriptable, which are run from keywords via a modifier (e.g., ⌘↩︎). However, they have a tendency to break when the command modifier is still being held (sometimes my thumb is a little lazy, ha). I've inserted some delays and things, but these can be finicky. I was hoping that Alfred - or some other scriptable solution - could check to see if any keys are being held down, and then just run the rest of the workflow once everything's been released (like Alfred's hotkey settings).

     

    Thanks for your help!

     

    @Andrew Would you consider adding this configure connection option at some point down the road (see above explanation)? For instance, here's one way it could be implemented on the UI side of things:

     

    setting.png.fd483fb2e553627640c5536e98146131.png

     

    Thanks for your consideration!

  8. @s95hc8 Are you still looking for a way to run a Finder fallback search?

     

    I came across your post today when searching for some help with something else, and I thought you might find the following workflow helpful: 

     

    https://gofile.io/d/dqJ7fx

     

    It's a simplified version of a workflow that I use to run Finder searches. In the past, I used to rely on a hacky GUI based approach, but this one works a lot better. It uses the Spotlight service; so, assuming you haven't deleted it, you should be in good shape. If you're curious, it's the service that pops up when you highlight text and select Spotlight from the context menu. It also doesn't matter what the actual hotkey is for it (System Preferences > Keyboard > Shortcuts > Services > Searching > Spotlight).

     

    Here's the basic setup (fallback search trigger + run script action):

     

    image.png.88423d220441fa5f59aa5ea8f9c4ad3c.png

     

    And, here's the key AppleScript:

     

    use AppleScript version "2.4"
    use framework "Foundation"
    use framework "AppKit"
    use scripting additions
    
    on run argv
    	set theQuery to argv as string
    	set pb to current application's NSPasteboard's pasteboardWithUniqueName()
    	pb's clearContents()
    	pb's writeObjects:{theQuery}
    	set theResult to current application's NSPerformService("SEARCH_WITH_SPOTLIGHT", pb)
    	pb's types()
    	set theArray to pb's readObjectsForClasses:{current application's NSString} options:(missing value)
    	set theString to theArray's firstObject() as text
    end run
    
    # Adapted From: https://forum.latenightsw.com/t/nsperformservice-in-applescript/836

     

    Cheers!

  9. @GuiB or @deanishe - By chance, do you guys know if there's a way to get Alfred to wait for a modifier release to occur when used with keywords (or script filters, for that matter)? In other words, is there a way to achieve what Alfred is doing with its hotkey trigger behavior (pictured above - wherein it will wait to kick things off until the keys are released), when configuring the connection from a keyword or script filter that's run via action modifier?

     

    I have a couple of GUI-based workflows for handling things that aren't scriptable, which are run from keywords via a modifier (e.g., ⌘↩︎). However, they have a tendency to break when the command modifier is still being held (sometimes my thumb is a little lazy, ha). I've inserted some delays and things, but these can be finicky. I was hoping that Alfred - or some other scriptable solution - could check to see if any keys are being held down, and then just run the rest of the workflow once everything's been released (like Alfred's hotkey settings).

     

    Thanks for your help!

  10. Hi @KennyP! Since posting this, @Andrew added the "Jump to" option to the "Action in Alfred" action, created Universal Actions, and even further improved things in Alfred 5. I think most of the key default actions are now accessible directly using "Action in Alfred" (with the "Jump to" option) or indirectly through other tools. But I'm sure there are still plenty of exceptions.

     

    Which file action did you want to use directly in your workflow? I'm not great with these things, but maybe I could help.

     

    FWIW: I'm with you, and would still like to see all of the default Universal Actions added directly to the "Jump to" dropdown in "Action in Alfred" (which was, in effect, what I was asking for above in #2). It would make things a lot easier than having to poke around and find what you're looking for. Cheers!

  11. Hi @vitor - Thanks again for the detailed feedback above! This is really helpful, and I think I'm on the same page with everything above.

     

    However, I still can't seem to get the file action to open both files at the same time. Instead, the Open With... file action always just opens one of the files it's passed. I must be missing something still?

     

    For testing purposes, I tried to simply place the string of file paths in the script, but I still run into the same problem (and tinkering with json.dump, etc.): similar to the following, but with changes to theName, of course

     

    import json
    import sys
    
    # theInput = "{query}"
    theInput = "/Users/theName/Desktop/1.pdf	/Users/theName/Desktop/2.pdf"
    
    theFiles = theInput.split("\t")
    config = {
        "alfredworkflow" : {
            "arg": theFiles[1:]
        }
    }
    json.dump(config, sys.stdout, indent=2)

     

    Is there something special that needs to be declared in the config so that Alfred's file action knows to try and open both of them at the same time (with the selected Jump to)?

     

    Thanks again for all of the tips above. And, I understand what you mean about the XY problem, simplifying the variables, etc. I was hoping to just get down a basic working example, so that I could go from there. Thanks!

  12. HI @vitor - Thanks a ton for the detailed explanation. It was incredibly helpful, and I think I understand what you mean by arguments versus file paths.

     

    I'm happy to report that since you and @deanishe last recommended that I start learning python—and stop relying on AppleScript so much—that I have been slowly picking up things here and there. As you can tell from the above, however, I often have a hard time applying things outside of those tutorials, such as in Alfred.

     

    In the above scenario, let's assume the file paths are coming in to the python script as a tab-separate string (e.g., "/Users/theName/Desktop/1.pdf /Users/theName/Desktop/2.pdf"). If I want to format that string appropriately, and then feed it directly to an Alfred action (whose Treatment = "File" and Jump to = "Open with..."), are you saying that the following will work:

     

    import json
    import sys
    
    theInput = "{argv}"
    theFiles = theInput.split("\t")
    
    config = {
        "alfredworkflow" : {
            "arg": sys.theFiles[1:]
        }
    }
    json.dump(config, sys.stdout, indent=2)

     

    In other words, I don't need to include any of the action's config-related information (e.g., path, type, jumpto)? 

     

    Sorry for being such a luddite here. And, thanks again for all of your help!

  13. Hi @deanishe - Thanks for getting back to me! I hope all is well on your end.

     

    Yeah, I was really hoping to feed the files to the "open with" file action, so I could select the appropriate app (as opposed to just opening it in the default or specifying the app myself, as you would need to do in the code above). I just like Alfred's UX for selecting the appropriate app more. 

     

    It's easy to feed files to Alfred's "open with" file action, when done one at a time. I just can't figure out how to send more than one via script. Obviously, Alfred's able to do it, given that it's already accomplished when files are directly selected and triggered via hotkey. Do you know the format that Alfred uses when handing macOS selections via hotkey? I should be able to use a python script to format the file paths accordingly, right?

     

    Thanks again for all of your help! Cheers!

  14. Hi @deanishe - By chance, do you know if it's possible to use a python script (similar to above) to feed more than one file to an "Open With" file action? I'm not sure if it's just a formatting problem, or if it's not possible yet with these newer file action options, but I haven't had any luck trying to update the the previous script.

     

    For example, I've tried several variations of the following python script below (where the incoming files are a tab separated string and this script feeds to an "Action in Alfred" with the "Open With" "Jump to" option selected):

     

    import json
    import sys
    
    query = "{query}"
    theFiles = query.split("\t")
    
    config = {
    	'alfredworkflow' : {
    		'config' : {
    			'path' : theFiles,
    			'type' : 1,
    			'jumpto' : 'alfred.action.openwith'
    		}
    	}
    }
    json.dump(config, sys.stdout, indent=2)

     

    As always, thanks for any help you can lend!

  15. @deanishe If you're feeding more than one file path into the "scopes" field, and they're coming into the JSON Config as a string, how do you convert the string back into a list, so that the File Filter knows how to read them (i.e., adding back the missing quotes around each file path in the input)?

     

    To explain, let's say the JSON Config receives the following string:

    • /Users/Name/Downloads, /Users/Name/Desktop

    If you set the scopes to "{query}", as in the standard way, the attached file filter won't work because the JSON isn't formatted correctly. Each file path needs its quotes, as follows:

    • "/Users/Name/Downloads", "/Users/Name/Desktop"

    Is there something that can be added to the JSON Config's incoming query that would add the missing quotes, so that it can work properly? For example, is there something I can add above the usual "{"alfredworkflow" : { ..." that will convert the string into an appropriately formatted/quoted list of file paths that I can use as the input/variable for "scopes"?

     

    Thanks for your help! This issue has been driving me crazy (short trip, I know - Ha).

×
×
  • Create New...