Jump to content

vitor

Staff
  • Posts

    8,471
  • Joined

  • Last visited

  • Days Won

    706

Posts posted by vitor

  1. That would add a bit of complexity and I worry might lead to foot guns. macOS launchd agents don’t run if your computer is turned off, so I’d hate for someone to not have a backup at a crucial time because the last one happened to be at an unlucky time and then the one they have is two weeks old or more. That’s why a time can be configured. The versioning is a secondary concern, the focus of the workflow is the backup.


    You could instead reduce the number of backed up versions. If by any reason you need an older version at some point, the last 30 days of them should be available to recover.

  2. It’s important to reiterate that Alfred’s Preferences are essentially a folder bundle of files. Alfred needs those files to be available at all times, and if a sync service is doing something funky to them or purging them, there’s only so much that can be done. iCloud Drive in particular has historically been unreliable (and Sonoma 14.4 in particular brought new bugs) which is why Alfred warns about it when setting it as the sync location.


    When disabling Optimise Mac Storage, make sure you wait before trying again, because it can take a while to download what you have online. You should also reboot your Mac, because the iCloud daemon can be unreliable.


    Also note you can backup your preferences with a workflow which allows you to keep you settings local while also periodically saving them to cloud storage.

  3. 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.

  4. 21 hours ago, sinled said:

    Is there any way to make it work "reactive" without unnecessary enter press?

     

    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.

  5. With the caveat that this isn’t a secure way to encrypt sensitive data (I know you understand that, I just want to hammer the point for people arriving to this issue later), a dead-simple way to do it would be to encode as Base64.


    Use a Universal Action connected to a Run Script Action connected to a Copy to Clipboard Output set to paste to the frontmost app. Then duplicate all that. You’ll use one set for encoding and the other for decoding. The only change is what the Run Script will contain.


    In the one to encode, set the code to /usr/bin/base64 <<< "${1}". In the one to decode, set it to /usr/bin/base64 --decode <<< "${1}". Done.


    You can see the Getting Started Guide for an interactive tutorial on making a workflow.

  6. 26 minutes ago, dan22 said:

    Could anyone let me know how to keep the Alfred Window open with the query results ?

     

    That’s not available, but you can copy the output (or just the last answer) with the shortcuts listed at the bottom

     

    20 minutes ago, CarREFuse said:

    Is there any plan that allows users to use different base url instead of OpenAI?

     

    See the first item in the FAQ.

  7. Welcome @sweetgrass,

     

    When sending text to a script you’re not doing it as continuous input but rather as an argument. In other words, you have to use $1. See Alfred’s placeholder text when creating a new Run Script with /bin/bash set as the language.


    But even so, the code can be greatly simplified. There is a command-line tool in macOS whose whole purpose is counting lines. You should be able to replace the whole code with a single line:

     

    /usr/bin/nl -ba -d. -s'. ' -w 1 <<< "${1}"

     

    Run man nl in a terminal for an explanation of the options.

     

    That should return the same format you’re looking for. Though personally I don’t like that numbers can push lines to the right, so I’d do something like:

     

    readonly digits="$(wc -l <<< "${1}" | tr -d '\n ' | wc -c | tr -d '\n ')"
    /usr/bin/nl -b a -d . -s '. ' -w "${digits}" <<< "${1}"

     

  8. I don’t know what to tell you more than what’s been said. The Alfred workflow follows the API.

     

    We’re not privy to your usage (nor do we want to be, we firmly believe in privacy and not collecting user data), but it does not seem accurate to say Alfred’s responses are always brief because the text comes 100% from the API response. There’s nothing that would cause shorter replies (and there have been no other reports of it) unless you’ve set up a system prompt to tell it to make brief answers (you can confirm that in the workflow’s configuration).

     

    Again, we don’t have (and don’t want to have) any control over how OpenAI charges you. The workflow follows the API as it is documented and this can be verified by looking at the code which is available in its entirety. If anyone spots an opportunity for optimisation (and I know lots of people have been looking at the code) they are welcome to suggest it. Anything further than that regarding your usage only OpenAI can say.

  9. 9 minutes ago, gingerbeardman said:

    Any plans to add support for Temp Mail? https://temp-mail.org/en/

     

    temp-mail is quite good, but not automatable like the others where you can predictably create an email address and open a page for it. I looked into it quite a while ago and abandoned it. I’m willing to add it if someone finds a way (not with the RapidAPI thing, that doesn’t fit well and is a hassle).

×
×
  • Create New...