Jump to content

vitor

Staff
  • Posts

    8,495
  • Joined

  • Last visited

  • Days Won

    708

Posts posted by vitor

  1. 3 hours ago, giovanni said:

    I was wondering if there is a better, more future-proof way.

     

    Short answer: bundle the dependencies. Lower the need to rely on the user’s environment.

     

    Long answer is below. With apologies to @Y1ng for having this long post in your Workflow’s thread. If you prefer, I can split these to another.

     

    3 hours ago, giovanni said:

    what if the package has a ton of dependancies?

     

    What specifically worries you in that scenario? Is it the extra size? I just downloaded it to a temporary directory with dependencies and it came to just under 20MB. Granted, that isn’t small, but is it worse than the alternative?


    Consider your case under the multi-python scenario in my previous comment. You ask a user to pip3 install audible-cli and they now have it under a Python that is managed by pyenv. But because (let’s imagine) the Workflow is assuming a Homebrew Python installation, it doesn’t pick it up and appears broken. What do you do then? You can refine your instructions to specify a Homebrew Python needs to be used, but considering a multitude of possible setups and that the path to a Homebrewed Python changes depending on architecture, you’re now spending half of the “About” from your Workflow explaining technical details which are irrelevant to most. Or you can have a Workflow Environment Variable where users add a custom Python path, and now you need to do a bunch of checks to ensure it exists, and how to react when it doesn’t, and the Python path is now dynamic and your code is harder to maintain. Or you can make your Workflow 20MB larger.


    What’s the best option? It depends. What do you value most? What do you believe the users of your Workflow value most? How close to your ideals can your current level of skill take you? How do different goals correlate? Is a 1MB increase in file size worth it for a program 100 times faster? What about 100MB for something 1.5 times faster? What about 20MB for extra convenience? How do you even measure convenience?


    There is always a tradeoff. Your goal is to identify and pick the best one for your situation.


    Let’s keep exploring your specific case from a size perspective. Python is popular. If every Python Workflow included a full runtime—even if it were small—the duplication would lead to considerable wasted bandwidth and space (including in the user’s cloud hosting, for synced settings). But what about audible-cli, how likely is it that a user of your Workflow already has it installed, for another Workflow or in general? If they’re more likely to not have it (seems likely), is the extra size worth skipping the hassle of having to set it up? For under 20MB, I’d say yes; if it were 500MB, I’d say no. But even that is relative. How much of a hassle are you saving?


    Will a user not use your Workflow because it’s hard to setup? Will another not use it because its file size is too big? Both can be true. Which of those weighs more? Which choice will make a better Workflow for most people? Which one will make a better Workflows for yourself, one that you’ll continue to have fun developing and be proud to offer support for, which will in turn be better for users?


    There are answers to all of these questions. Though yours may be different than mine and they may change with time.

     

    Apologies for the length of the post. Given more time I’d have made it shorter and all that, but it’s dinner time. Have a nice evening.

  2. 10 minutes ago, giovanni said:

    If we do want the user to install a nonstandard package with /path/to/python -m pip install --user myPackage, how do we point to the package (i.e. how do we get /path/to/python) in the workflow?

     

    You don’t. That paragraph applies in general, like installing it for yourself. If it’s for a Workflow, follow the first paragraph: bundle the package with the Workflow instead of asking the user to install it. That is significantly easier for users because they don’t have anything to setup and is beneficial to you because you know what version is used.

     

    It should be something like /path/to/python -m pip install --target "/CUSTOM/DIRECTORY/PATH" "PACKAGE_NAME" and then using export PYTHONPATH="/CUSTOM/DIRECTORY/PATH" before calling your script to ensure the package is available.

     

    13 minutes ago, giovanni said:

    Is there a way to point to the most recent Python installation

     

    Not really. You can try to guess but that doesn’t give you guarantees. A user may have, at the same time, /usr/bin/python3 (from the developer tools), /opt/homebrew/bin/python3 (installed as a dependency for another Homebrew package), and ~/.pyenv/shims/python3 (version-managed with pyenv). They may have only wanted (and directly use) the last one, but the others exist nonetheless (cue XKCD).

     

    19 minutes ago, giovanni said:

    or should we ask the user to run which python and then enter the path in a workflow variable?

     

    You want to avoid that, for the benefit of both users and yourself. Extra manual steps you require, especially technical ones, increase your support burden. You should either use /usr/bin/python3 directly (macOS will prompt the user to install it if they don’t have it, and that’s done in two clicks) or require a Homebrew-installed Pyhton and use that path (not directly, use export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}" due to the different Homebrew locations).

     

    @Y1ng Since you’re just calling python, this point is particularly relevant. Starting next week, with the release of macOS Monterey 12.3, that will no longer be available.

     

    16 minutes ago, giovanni said:

    also, should we use pip3 (and which python3) going forward?

     

    Yes, you shouldn’t be using Python 2 anymore. Or anything below 3.6, for that matter.

  3. 1 hour ago, Tobi from Munich said:

    doesn't do a thing within the browser. Literally nothing, no key is pressed.

     

    Are you sure ⌘K is the right shortcut and that doing it manually results in the desired behaviour? I don’t use ClickUp so I can’t go through all steps but everything looks to be working.

     

    Do note that the second Copy to Clipboard needs to have {clipboard}, not {query}, because otherwise you’re copying the passed website address.

  4. The way you’ve organised your screenshot is interesting and clear. But for future reports, it’s best if you upload the Workflow somewhere and provide a link. That’s less work for you and is more helpful to anyone helping. Doing both is even better, but if you can only do one pick sharing the Workflow because that allows us to try it in context.

     

    On with the problem.

     

    4 hours ago, Tobi from Munich said:
    set {query} to the clipboard as string

     

    You’re conflating Alfred features with AppleScript code. {query} doesn’t come into play here because you’re (correctly) using with input as argv. The though process is reversed: that code is to store the clipboard contents into a variable, not make the given argument become the clipboard contents. Long story short, get rid of that line as it’s not doing anything.


    Another likely problem is that despite you having a large delay at the top, you don’t have any between the two keyboard shortcuts. That’s part of the perils of GUI automation, you always need to ensure everything has waited enough time. Try:

     

    tell application "System Events"
        delay 10
        keystroke "k" using {command down}
        delay 5
        keystroke "v" using {command down}
    end tell

     

    And adjust the second delay accordingly. Or better yet, use Alfred’s native objects: Delay Utility (wait) → Dispatch Key Combo Output (press shortcut) → Delay Utility (wait again) → Copy to Clipboard Output (paste)

  5. 4 hours ago, grovolis said:

    When using a light Alfred theme, the font colour does not adjust, making it harder to read text. Could you adjust that?

     

    Font colour is determined by your theme; Workflows don’t have control over that.

  6. Welcome @timrosenberg,

     

    Processes which allow you to make calculations on time typically require that you be specific with the date. That is to say you wouldn’t do 9:00 + 4h but March 10 2022 at 9:00 + 4h (consider what happens when it goes over to the next day; it has to be represented).


    If you only want to add hours, you’re looking at simple arithmetic: (9 + 4) % 24. The % is the modulo operator. Doing it on 24 will make it “flip over” according to a 24h clock (example: (17 + 9) % 24 = 2 or “5PM plus 9 hours equals 2AM”). You can try these in Alfred’s main window by starting with = then typing the operation.


    If you want to use this in a Workflow, you’ll have to be more specific in your request. Right now it’s so broad it approximates an XY problem so there’s yet no way to know what the best answer is.

  7. On 3/8/2022 at 9:09 PM, Afoan said:

    I'm sorry but what's the difference between this workflow and "Apple Reminders" by "Acidham"

     

    What exactly are you trying to discern? Different developers build Workflows in different ways, with different languages, and give weight to different features. You should use whichever you like the most and fits your mental model better.


    Do note this one is in maintenance mode. @Acidham’s is still being updated.

  8. Welcome @Pchecoandres,

     

    7 hours ago, Pchecoandres said:

    I wonder if Alfred is not refreshing its search engine or something

     

    No, that is unrelated. From the moment you start the Script Filter, it becomes the Workflow’s responsibility to show results.

     

    7 hours ago, Pchecoandres said:

    I've tried to fix it

     

    How? If you don’t specify what you’ve done, it’s not possible to know what went wrong. Use the debugger to see what’s happening. At the very least, you’ll probably need to install PHP.

     

    Note this Workflow was last updated a decade ago. It may still work fine or it may not work at all because in the meantime Parallels may have changed their system significantly. @flakshack’s top post has other tips on how to remake this with some manual work (namely a File Filter, but you could also try a List Filter). Alternatively, there may be another Workflow which does this.

  9. I haven’t tried it but your assumptions seem correct. Do note that since the synced preferences are a directory, Dropbox should only sync what changes inside. That is to say in your unlikely scenario where you make changes on both accounts without internet connection, you’d have to make changes to the same path for there to be a problem.

     

    Even if that did happen, Dropbox should offer you conflict resolution (“which file do you want to keep”), though that is best avoided. Consider making regular backups of your Alfred preferences, at least until you feel confident in your system.


    Alternatively, you may want to try /Users/Shared as a location for your preferences. That way you guarantee they are synced between accounts and don’t have to worry about connectivity.

  10. 6 minutes ago, Pyetro said:

    Lose Pinboard would be a huge pity


    I doubt Maciel would just abandon it. It makes money and one of his frequent quips is how every other bookmarking service falls by the wayside. If he got tired of it, maybe he’d go into maintenance mode and get someone to manage it. I think he did something similar when he went to Antarctica.

     

    13 minutes ago, Pyetro said:

    otherwise I'll try to ask to Macej directly


    That might still be worth it. He’s usually responsive and interested in knowing about errors. Worth pointing out the blog is down as well.

  11. On 3/8/2022 at 9:59 PM, jxxst said:
    [13:52:22.070] ERROR: Swift Test[Run Script] zsh:27: parse error near `}'

     

    Are you pasting the code into the Script box? You’re trying to use Zsh to run Swift code. Set the language to External Script instead and put the code in the file.

     

    On 3/8/2022 at 9:59 PM, jxxst said:

    This script gives only availability for today and doesn't support the next X days, but it seems easy to refactor.

     

    Increasing the 1 in the line below to however many days you want to check in advance might work. But it might not: I have neither dealt with the Calendar API nor have I thoroughly checked the rest of the script to see if there’s something else which would make it not work well for multiple days.

     

    On 3/8/2022 at 9:59 PM, jxxst said:
    let endOfToday = Calendar.current.date(byAdding: .day, value: 1, to: startOfToday)!
    
  12. 8 hours ago, Smpl said:

    If its better than I create a new Topic for the Script Filter question (or whatever is needed to be used instead) to obtain the playlists automatically from the Music app, then I will.


    No, this one is fine. “One problem at a time” is what matters.
     

    What exactly is the new question? What’s your current setup and what result are you trying to achieve?

  13. 1 hour ago, Smpl said:

    because it hides the annoy google search

    1 hour ago, Smpl said:

    but again with the annoying google search

     

    If you don’t like it, you can turn it off. Alfred Preferences → Features → Default Results → Fallbacks.

     

    1 hour ago, Smpl said:

    But I added a Playlist option to the flow, but have to manually add the playlist names to the List Filter.

    Is it possible to get the playlist using the Script Filter?

     

    That’s an entirely unrelated problem. If you want to use a Script Filter, don’t use AppleScript because you’ll need JSON. Use JXA instead.

     

    1 hour ago, Smpl said:

    But don't know how it outputs the results

     

    Run the command in the Script Editor app.

     

    1 hour ago, Smpl said:

    or what I need to output them to?

     

    Script Filter JSON Format.


    But again, that has nothing to do with the original question. If you start with a simple query and then introduce an unrelated complex one midway through, it won’t be easy to help you.

  14. You tell Alfred to use Language /bin/bash or /bin/zsh in the script editor and add export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}" as the first line, like you have in the screenshots. Under that, put the path to your script. If the script is in the Workflow directory, use ./myscript.mjs. . represents the current directory (.. is the parent), so ./myscript.mjs means “the myscript.mjs file in the current directory”.

×
×
  • Create New...