Jump to content

vitor

Staff
  • Posts

    8,471
  • Joined

  • Last visited

  • Days Won

    706

Reputation Activity

  1. Like
    vitor got a reaction from protonymus in File filter results in grid view   
    There is not, by design¹. Think about that interface: you’d be typing something in Alfred and then the whole interface would change from under you to something different, and then you wouldn’t be able to continue typing to something else or go back² or else you would be able to do that but not filter in the view and have the interface going back and forth. The new views are separate paradigms, and to allow their full potential there can’t be ambiguity.

    That said, while showing all files would have major performance implications, listing a specific file type is more doable. All you need is a Run Script Action before the Grid View set to /usr/bin/swift as the Language with this code (quick adaptation from another workflow):
     
    import Foundation // Change this to what you want to search let query = "kMDItemContentType == com.adobe.pdf" // LEAVE UNTOUCHED FROM HERE // Prepare query let searchQuery = MDQueryCreate(kCFAllocatorDefault, query as CFString, nil, nil) MDQuerySetSearchScope(searchQuery, [("~" as NSString).expandingTildeInPath] as CFArray, 0) // Run query MDQueryExecute(searchQuery, CFOptionFlags(kMDQuerySynchronous.rawValue)) let resultCount = MDQueryGetResultCount(searchQuery) // No results guard resultCount > 0 else { print( """ {\"items\":[{\"title\":\"No Results\", \"subtitle\":\"No paths found matching query\", \"valid\":false}]} """ ) exit(EXIT_SUCCESS) } // Prepare items struct ScriptFilterItem: Codable { let uid: String let title: String let subtitle: String let type: String let icon: FileIcon let arg: String struct FileIcon: Codable { let path: String } } let sfItems: [ScriptFilterItem] = (0..<resultCount).compactMap { resultIndex in let rawPointer = MDQueryGetResultAtIndex(searchQuery, resultIndex) let resultItem = Unmanaged<MDItem>.fromOpaque(rawPointer!).takeUnretainedValue() guard let resultPath = MDItemCopyAttribute(resultItem, kMDItemPath) as? String else { return nil } return ScriptFilterItem( uid: resultPath, title: URL(fileURLWithPath: resultPath).lastPathComponent, subtitle: (resultPath as NSString).abbreviatingWithTildeInPath, type: "file", icon: ScriptFilterItem.FileIcon(path: resultPath), arg: resultPath ) } // Output JSON let jsonData = try JSONEncoder().encode(["items": sfItems]) print(String(data: jsonData, encoding: .utf8)!)  
    All you need to do is change the text between quotes at the query line near the top. Currently it’s set for PDFs; PNGs would be public.png. Other file types are left as an exercise to the reader, but here’s a list.



    ¹ Technically you can, by using something like a Hotkey, but I don’t think that’s what you mean. You could also fudge it with an External Trigger, which I do not recommend at all.

    ² Because how would Alfred know if you were refining the input in the new view or changing to another one.
  2. Like
    vitor got a reaction from JJJJ in Backup Preferences — Create and restore Alfred Preferences backups   
    Usage

    Generate a backup of your local Alfred Preferences via the start backup keyword. A macOS launchd agent will be loaded to do it daily at the time set in the Workflow’s Configuration (using the 24-hour clock format). The number of versions to keep is likewise configurable.



    Restore a previous version with the restore backup keyword. It takes a few seconds to complete and restarts Alfred.



    ⤓ Install on the Alfred Gallery | Source
  3. Like
    vitor reacted to MaxC in Alfred 5.5.2257 remove workflow not working with iCloud   
    There was a brief happy moment right before Sonoma 14.4 when iCloud became surprisingly reliable, then they broke it again.
     
    For now I added Alfred preferences copying into my hourly cron script, which I use for situations like these.
  4. Like
    vitor got a reaction from sepulchra in Simple Ideas: chewing the FAT (Universal Actions for files)   
    And so incredibly simple. A contender for the shortest code: /bin/cat "${@}".
  5. Like
    vitor reacted to sepulchra in Simple Ideas: chewing the FAT (Universal Actions for files)   
    I love the File Contents automation task. It is so incredibly useful.
  6. Like
    vitor got a reaction from Stephen_C in Simple ideas: opening a frequently used folder   
    I’ll ask that we please not bring more separate discussions into this thread, which is supposed to be about one Simple Idea that Stephen is kindly sharing with the community. Words of appreciation and requests for clarifications are certainly welcome, but (especially) since this post is part of a larger collection I’d rather we don’t derail it further.

    I’ve posted a reply on the other post.
  7. Like
    vitor got a reaction from Alan He in Paste/Insert text/snippets without using the clipboard in remote desktop (RDP)   
    Welcome @Soprano,
     
    You can use Alfred to trigger an AppleScript to send keypresses, but will those be sent to the RDP session? It might depend on your session settings or it might not be doable at all. Try this Workflow. Edit the object in the middle to write the text you want to send and try it out.
     
  8. Like
    vitor got a reaction from ebleble in Regular expressions support for file search   
    Welcome @ebleble,
     
    Alfred uses the Spotlight metadata. You don’t need glob patterns (regular expressions are similar but distinct) and can just type somephrase pdf or pdf.
  9. Like
    vitor got a reaction from ebleble in Regular expressions support for file search   
    What you seem to be looking for is fuzzy finding. FZF is a community workflow for that.
  10. Like
    vitor got a reaction from Alan He in How find snippet in my Collections?   
    In Alfred Preferences → Features → Snippets, you can add a Hotkey for the Viewer which allows you to search. Alternatively: Alfred Preferences → Features → Clipboard History → Snippets.
  11. Like
    vitor got a reaction from iJemz in Create a long list of snippets and use fuzzy matching to search them   
    Instead of Snippets, you’re looking for a List Filter Input (you can load a CSV into it) connected to a Copy to Clipboard Output.
     
    See the Getting Started Guide for an interactive tutorial on making a workflow.
  12. Like
    vitor reacted to Gold in ChatGPT / DALL-E - OpenAI integrations   
    Got it. It's no real problem to me as long as it's expected behavior. I appreciate the attention to the matter.
  13. Like
    vitor got a reaction from sepulchra in Where’s the Binary — Get the full path to executables in your PATH   
    Usage

    Search for executables in PATH via the whereis keyword.


    ↩ Copy original path. ⌥↩ Copy resolved path if original is a symbolic link.
    ⤓ Install on the Alfred Gallery | Source
  14. Like
    vitor got a reaction from Alan He in Where’s the Binary — Get the full path to executables in your PATH   
    Usage

    Search for executables in PATH via the whereis keyword.


    ↩ Copy original path. ⌥↩ Copy resolved path if original is a symbolic link.
    ⤓ Install on the Alfred Gallery | Source
  15. Like
    vitor got a reaction from zeitlings in Where’s the Binary — Get the full path to executables in your PATH   
    Usage

    Search for executables in PATH via the whereis keyword.


    ↩ Copy original path. ⌥↩ Copy resolved path if original is a symbolic link.
    ⤓ Install on the Alfred Gallery | Source
  16. Like
    vitor reacted to caleb531 in Pre-populating a Text View's Script Input field with an initial value   
    @vitor I have at least considered that, although depending on how they edit the preview, it may not be clear how to derive the new format string. My hope is that because the Script Input and the Text View response are both displayed as separate things, that I could allow them to edit the format string and see a live preview of how it would render out. It would be the best of both worlds. And if they enter an invalid syntax for the format string (within the Script Input field), then the Text View response body would display an appropriate error message in place of a rendered preview.
     
    But you still make an interesting argument. If I relinquish my need for a preview, I could render the format string into the Text View response body in Editable mode. Then I could perhaps use the footer text to render out any error messaging. I will look into this. Thank you!
  17. Like
    vitor got a reaction from naukc in ChatGPT / DALL-E - OpenAI integrations   
    @naukc You need to install the Automation Tasks.
     
    @3point ChatGPT (and any other LLM) doesn’t “know” anything, it strings text together. Check OpenAI’s own models page; GPT-4’s cut-off date is April 2023 while GPT-3’s cut-off date is September 2021. So the answer you were given is contradictory, it can’t both have a cut-off date of April 2023 and be GPT-3. In other words, you are using GPT-4. Asking it what model it is is particularly unreliable, I’ve been reproducing that wrong answer for quite a while.
  18. Like
    vitor got a reaction from 3point in ChatGPT / DALL-E - OpenAI integrations   
    @naukc You need to install the Automation Tasks.
     
    @3point ChatGPT (and any other LLM) doesn’t “know” anything, it strings text together. Check OpenAI’s own models page; GPT-4’s cut-off date is April 2023 while GPT-3’s cut-off date is September 2021. So the answer you were given is contradictory, it can’t both have a cut-off date of April 2023 and be GPT-3. In other words, you are using GPT-4. Asking it what model it is is particularly unreliable, I’ve been reproducing that wrong answer for quite a while.
  19. Like
    vitor got a reaction from Alan He in ChatGPT / DALL-E - OpenAI integrations   
    Frequently Asked Questions (FAQ)

    How do I set up an alternative AI model?

    The workflow offers the ability to change the API end points and override model names in the Workflow Environment Variables. This requires advanced configuration and is not something we can provide support for, but our community are doing it with great success and can help you on a different thread.

    How do I access the service behind a proxy?

    Add a new https_proxy key in Workflow Environment Variables. Or configure the proxy for all workflows under Alfred Preferences → Advanced → Network.

    Why can’t I use the workflow with a ChatGPT Plus subscription?

    The ChatGPT Plus subscription does not include access to the ChatGPT API and are billed separately.

    Is there a video which shows how to use the workflow?

    Yes, on YouTube.

    How do I report an issue?

    Accurate and thorough information is crucial for a proper diagnosis. When reporting issues, please include your exact installed versions of:
    The Workflow. Alfred. macOS. In addition to:
    The debugger output. Perform the failing action, click “Copy” on the top right and paste it here. Details on what you did, what happened, and what you expected to happen. A short video of the steps with the debugger open may help to find the problem faster.
  20. Like
    vitor reacted to csjaugustus in Is it possible to use a Python script with Text View?   
    That totally solved it. Thanks a lot for your detailed explanation!
  21. Like
    vitor reacted to Stephen_C in Simple Ideas: double trouble—hidden delights of the Keyword Input   
    Background
    Alfred's Keyword Input is more versatile than you might at first suppose. Of course you can use a keyword without any argument: I use one like that to open a deeply nested menu item in Day One.

    However there's much more you can do with the Keyword Input.

    The skeletal workflow


    Explanation
    1. In order to set your teeth on edge we'll use the keyword Fraze. If we double click on the Keyword Input this is what we see:


    It shows the keyword we're using to trigger the workflow and indicates that should be followed by <space>, an argument then ⏎. The argument is the first part of the phrase.

    Note the title forms a helpful prompt we'll see when we trigger the workflow. Prompts are really important and helpful prompts really facilitate the use of workflows—so make use of them!

    If we trigger the workflow we can type the first part of our phrase:


    Note we've sensibly added a space at the end of the phrase because we know we're going to add a second part. However, never trust users! So, after…

    2. Telling Alfred not close his window (explained in this post)…

    3. We take control of spaces, decide to deal with them ourselves in order to avoid nasty surprises, so use an Automation Task simply configured (by double clicking on it) to remove trailing white space.

    4. We save the first part of the phrase to a variable:


    We use a variable because we want to take control of assembly of the phrase.

    5. It's time to prompt for the second part of the phrase and to reveal a very neat trick of Keyword Inputs:


    This time we don't use any keyword. This Keyword Input is simply a device to collect more user input in the course of the workflow. We still require an argument (the second part of the phrase) so we leave that as is. Note again we have a helpful prompt. This one reminds the user of the first part of the phrase by using the variable we created in 4 above but with an added ellipsis and quotation marks.


    6. After again telling Alfred not to close his window…

    7. We use another Automation Task to trim white space—but this time from the start of the second part of the phrase just in case a user has tried to be clever.

    8. At last we can assemble the whole phrase:


    Our variable introduces and quotes the phrase and takes control of the spacing between the two parts of the phrase.

    9. All we then need to do is to put our variable into Alfred's Large Type Output:


    so that when the workflow runs with our inputs it shows Your phrase is: 'Spam is significantly overrated'. You don't really need another screenshot just to show that it works, do you?

    In conclusion
    You can use a Keyword Input without a keyword to scoop up more user input in the course of a workflow—and, of course, you can do that as many times as you need. However, do remember to provide users with helpful prompts when they have to respond to any Keyword Input that requires user input.

    Stephen

    The Simple Ideas posts
  22. Like
    vitor got a reaction from iandol in ChatGPT / DALL-E - OpenAI integrations   
    Thank you.
     
     
    That is correct.
     
     
    Make a new workflow with a Keyword Input and connect it to an Arg and Vars Utility with your custom text plus {query} for the new input from the Keyword. Then connected it to a Call External Trigger Output set to open continue_chat from this workflow.
  23. Like
    vitor reacted to zeitlings in Keyword followed by variable not working   
    The script filter expects a specific JSON object as a result that contains information about what to display. Instead of echoing the argument directly, you have to wrap it in this format if you want it to "see" what you typed. Otherwise Alfred will jump to the default fallback because it doesn't know what to do. There is a script filter example under the "getting started" section when creating a new workflow that lets you inspect the format.
     
    In short, you would want to do something like this:
     
    local input="placeholder" [[ ! -z "$1" ]] && input="$1" cat << EOB {"items": [ { "title": "$input", "subtitle": "$input", "arg": "$input" } ]} EOB  
  24. Like
    vitor reacted to Stephen_C in Simple Ideas: the Big Bang & Universal Actions   
    Background
    Approximately 13.8 billion years ago the universe exploded from a hot, dense soup of sub-atomic particles and has been expanding ever since. You are part of the expanding universe.

    Approximately 32 months ago Universal Actions exploded from Alfred 4.5 and have been expanding ever since. You can also be part of expanding Universal Actions: find out how—and why—it's better not to remain in a hot, dense state.

    There are few skeletons (just one) in this tiny cupboard in the universe: we don't start with a skeletal workflow. We have—horror—a non-standard layout for this "Simple Ideas” post.

    What are Universal Actions?
    At its most basic a Universal Action is an action in Alfred that acts on something you have selected: a file, a URL or text. However a Universal Action can also act on Alfred's results, file navigation or clipboard history (see below).

    Alfred has a large list of inbuilt Universal Actions. You can see them by opening Alfred Preferences → Features → Universal Actions and clicking on the Actions tab. While you're there you can un-check any that you don't want to see.

    How do I use a Universal Action?
    1. You can first select something (a file, a URL or some text) to use a Universal Action. When you have done so you can use your Universal Actions Selection Hotkey (go to  Alfred Preferences → Features → Universal Actions: it's ⌘/ by default) and that will display a list of Universal Actions relevant to what you have selected (i.e., text, file or URL).
    2. You can also use Universal Actions on Alfred's search results, File Navigation and Clipboard History. In those cases, simply use your Actions shortcut to show the Universal Actions relevant to the appropriate item. (The Actions key is set in  Alfred Preferences → Features → Universal Actions under Show Actions: and is → by default.)

    Here's what I see when I use Alfred to go to my ~/Downloads folder and then use →:


    (Your view will not be identical because you'll not have the same Universal Actions. Note also that Alfred remembers which Universal Actions you last used so the results will be ordered accordingly.)

    If I use Clipboard History, choose an item with text on the clipboard and press → I see this:


    Note that Alfred knows whether what you have selected is a folder or text (or, indeed, a URL). The beauty of Alfred's Universal Actions is that they're omnipresent (the clue may be in the name), intelligent and instantly accessible.

    I want to live in my own universe: how do I create a Universal Action?
    This is very easy. Here's a really simple example which converts text to lower case <produces following skeleton from cupboard>:


    We start with a Universal Action (which is probably not a major surprise to alert readers):


    We give it a name (remember, that's what's going to appear in our list of Universal Actions whenever, one way or another, we select some text), choose Text as its target and Single Input Arguments. (The alternatives are Single, Single and Multiple and Multiple: you can imagine the latter two are particularly useful when we're dealing with files, for example.)

    2. Connected to the smart little Transform Utility…


    3. …we simply then copy the result to the clipboard by using the Copy to Clipboard action in its default state.
     
    The result, of course, is that any capital letters in the text are now converted to lower case (you don't really need another screen shot, do you?).

    In conclusion
    27% of the Alfred workflows I use (numbering just over 100) are Universal Actions (or use a Universal Action in addition to another trigger). Those of course, are in addition to Alfred's inbuilt Universal Actions. Perhaps that's some indication of their usefulness…and it didn't take (even) me 13.8 billion years (or even 32 months) to build them.

    P.S. Alfred's File Action Trigger is important in the context of Universal Actions but you will be relieved to know there is a limit to the amount that should be crammed into one post so that will be the subject of a separate post…at some time.

    Stephen

    The Simple Ideas posts
  25. Like
    vitor got a reaction from ThanhD in ChatGPT / DALL-E - OpenAI integrations   
    Updated to 2024.6.
    Add chat history feature. Add option to archive images. Add Fallback Search. Add option to start new chat to Universal Action and Fallback Search. Do not close window on relevant steps. Support Organisation ID. Add model override for ChatGPT.

×
×
  • Create New...