Jump to content

luckman212

Member
  • Posts

    379
  • Joined

  • Last visited

  • Days Won

    15

Everything posted by luckman212

  1. @vitor is correct. I want to programmatically go to a specific object. Hope this will be possible some day!
  2. I thought maybe I would be able to use AppleScript for this but I couldn't find anything in Alfred's dictionary to make it happen.
  3. As my workflow library grows and becomes more complex, I find myself using the search feature to find objects more often. I wanted to know if it was possible to trigger this action from the workflow itself (same thing as executing "?epoch" from Alfred). I would like to e.g. take the output from a script filter which in this case could be the word "epoch" and directly have Alfred Preferences open with the object highlighted with those purple lines as it is below: E.g.
  4. Just want to add a final note, that as clever as @vitor's solution is, it would still be a nice feature to have a native and more portable way to do this directly via a JSON directive without abusing the uid field. So the FR still stands.
  5. @vitor So simple and works brilliantly! Thank you again for the help. I learned quite a few things today.
  6. Ah, wow I didn't know that! Ok that should indeed work then (passing variables) I will give it a shot! 🙂
  7. Thanks @vitor for your always inspiring and clever solutions. But, I think in this case, it wouldn't work for me, because I am not using rerun. I am talking about typing in Alfred's box, which causes the script filter to re-execute completely. I guess I could store the uidSeed on disk somewhere and check if its mtime is >5 sec old or something but that seems about as clunky as what I've come up with before. I can share my workflow if you want, it's called "border" and allows you to pick images from your clipboard history and apply borders & shadows (uses ImageMagick under the hood) of various sizes and colors to them...
  8. related threads/comments: https://www.alfredforum.com/topic/16760-selecting-a-result-while-rerunning-a-script-filter/?do=findComment&comment=86031 https://www.alfredforum.com/topic/16297-way-to-sort-keyword-trigger-matches-before-matched-applications-default-results/
  9. Problem: I have some script filters where I wish the items to be listed in the precise order they were output by the script. BUT, I also want to maintain the selected/highlighted item even when changing the arguments in Alfred's input box. Currently, to do that you must set a uid: within your JSON (ref.). The problem with this is, as soon as you action your first item from that script, the next time you invoke it, that item is floated to the top. So, catch-22. My "Poor Man's Solution" I wrote this small script that wipes out Alfred's knowledge for a specific script filter object after actioning. This works, but feels like a pretty ugly and inefficient hack. Call the script after your script filter using bash and pass as a paramter the name of your script filter object e.g. #!/usr/bin/env bash nohup "alfred_reset_knowledge.sh" "MyFancyScriptFilter" & *nb: requires: jq and plist2json.py #!/usr/bin/env bash [ -n "$1" ] || exit # obtain object ID KDB="$HOME/Library/Application Support/Alfred/Databases/knowledge.alfdb" mapfile -t objIds < <( plist2json.py info.plist | jq -r --arg name "$1" 'objects.objects | map(select( .type=="alfred.workflow.input.scriptfilter" and .config.keyword==$name ))[] | .uid') if (( ${#objIds[@]} > 0 )); then # short pause to allow Alfred to upate SQLite db sleep 1 for oId in "${objIds[@]}"; do #reset knowledge echo "resetting knowledge for object $oId" 1>&2 sqlite3 "$KDB" "DELETE FROM 'latching' WHERE item LIKE \"${oId}%\";" sqlite3 "$KDB" "DELETE FROM 'knowledge' WHERE item LIKE \"${oId}.%\" AND hidden IS NOT 1;" done fi Wish: - a parameter we could use within the script filter JSON to indicate to Alfred NOT to update the knowledge db when actioning this item (or the entire script). E.g. single item: { "uid": "foo123", "title": "Foo", "arg": "123", "knowledge": false <== } entire script filter: { "rerun" : 1, "knowledge": false, <== "items": [ ... ] }
  10. For now I ended up using a small helper function, this allows passing rt=None,False,0 etc... without causing an issue def json_out(d, rt=None): d_out = dict(items=d) if isinstance(rt, (float,int)): if 0.1 < rt <= 5.0: d_out["rerun"] = rt else: print(f'rerun ({rt}) is OUT OF RANGE 0.1-5.0', file=sys.stderr) json.dump(d_out, sys.stdout, indent=2)
  11. Hi, Alfred 4.6.3 [1285] macOS 12.2.1 I'm working on a Python workflow and am making use of the rerun parameter. So far so good. BUT, sometimes depending on the workflow inputs or outputs, I do NOT want it to rerun. I've tried the following variations, but using None or False results in the workflow never displaying any output (even though the JSON looks correct in the debug console) a) json.dump(dict(rerun=False, items=items, sys.stdout, indent=2) b) json.dump(dict(rerun=None, items=items, sys.stdout, indent=2) c) json.dump(dict(rerun=0, items=items, sys.stdout, indent=2) The only flavor that "works" is rerun=0, although that results in an orange WARNING from Alfred that WARNING: Foo[Script Filter] Script rerun of 0.00 is out of range (0.1s to 5s), rerun will be ignored —so that seems like a bad solution. I realize I could make some extra code paths in my script to account for these edge cases when I don't want the rerun to happen, but I'd love it if I could just keep it DRY and use the same json.dump() for everything. Is this a bug or a feature request?
  12. Great. Yes I suggest you learn a little more about the Workflows, they are very powerful. Each workflow has its own variables. Start here: https://www.alfredapp.com/help/workflows/advanced/variables/
  13. @noisyneil sure, all you would need to do is edit the "dest_dir" workflow variable and set it to just "Desktop":
  14. I haven't tested with the previous "official" build FYI so not sure if this is a new bug introduced in the latest beta
  15. I tried to set rerun=10 and got this warning: [14:49:32.573] WARNING: FooTest[Script Filter] Script rerun of 10.00 is out of range (0.1s to 5s), rerun will be ignored Why is the rerun value capped at 5s? Any reason? I have a script that I'd like to rerun every 10s, for example...
  16. macOS 12.2.1 Alfred 4.6.3 [1284] Here's an example Workflow to illustrate the (bug?) https://github.com/luckman212/alfred_bugs/blob/main/uid test.alfredworkflow.zip?raw=true Type "uid x" to invoke it, then try actioning the 2nd or 3rd item (they are all set to valid: false). Now, if you type "uid x " (note extra space at the end!) the items maintain the correct sort order. Here's a video... https://user-images.githubusercontent.com/1992842/153678417-f6c2174b-f936-43d9-8193-e33f5ba3eb0b.mp4
  17. @gmile When you run those commands from your shell, the PATH will have been inherited from whatever environment / rc / profile scripts were sourced. This could be things like .bashrc, .bash_profile, etc. Not sure what fish uses but you get the idea. Alfred won't run those, so either manually set a PATH environment variable that includes /usr/local/bin or adjust your script's shebang to point to the absolute path to elixir instead of relying on env... #!/usr/local/bin/elixir
  18. https://github.com/FrodeSolheim/fs-uae-launcher/issues/141 http://eab.abime.net/showthread.php?t=109585
  19. Thanks @vitor - good advice. I tried to register on their support forum to post the issue but as of now my status is 'pending' and I can't post yet. Deleting the app for now, as I'm not really using it. Once I did that, the "problem" in Alfred went away. Will follow up later.
  20. @Vero I had a bit of a dig into this. I think I figured out why it's happening. I looked into the Info.plist of the offending app (FS-UAE) and found what appears to be an invalid bit (the CFBundleIdentifier is null): This hasn't caused other problems (that I'm aware of) but I assume that somehow it's tripping Alfred up.
  21. Has anything changed since 2016? I recently learned about globally adding to launchd's PATH using e.g. sudo launchctl config user path "$(brew --prefix)/bin:${PATH}" But Alfred as of 4.6.1-1274 still seems to ignore this? Any way to get him to honor the custom PATH env var? edit: gets a bit weirder... actually Alfred DOES honor this, but not upon first launch after login (auto-start). Only after you quit Alfred and then re-launch him, will he then inherit the new PATH. Strange, I guess maybe there's some race condition happening during login where Alfred launches somehow before launchd has a chance to update things?
  22. Here's a screenshot (no, FS-UAE is not in the list) Yes, I tried in a fresh new workflow, it shows that same erroneous icon... Surely, I just did that. (btw: the workflow is just the default "Google Suggest" workflow from Examples, v1.4)
  23. macOS 12.0.1 Alfred 4.6.1 [1273] I noticed this harmless little bug: In the workflow editor, a random(?) icon is shown to represent the default system browser. Here it is picking up the icon from an app called "FS-UAE Launcher" on my system: If you double click the object, the correct browser/icon is shown: I tried re-setting my Default Browser prefs in System Preferences > General, quitting & relaunching Alfred but it didn't change. Regardless, the correct browser does actually open, so this is purely cosmetic.
  24. @Vero Thanks for you help on this. I eventually tracked this down to what appears to be a macOS bug. I was setting the Finder comment (and they were appearing in the Get Info box, as shown in my earlier screenshots!) but somehow, the metadata was not actually being populated. Your tip on using the Alfred Metadata Tool was really helpful in identifying this. I ended up using osxmetadata to set the comment (combined with sudo), and that seemed to work. sudo osxmetadata --set com.apple.metadata:kMDItemFinderComment 'alfred:ignore' -- "/Applications/Utilities/Adobe Creative Cloud/ACC/Creative Cloud Helper.app" Once I sorted that, all working fine now! ☺️
×
×
  • Create New...