Jump to content

luckman212

Member
  • Posts

    412
  • Joined

  • Last visited

  • Days Won

    16

Posts posted by luckman212

    • Alfred 4.6.5 [1298]
    • macOS 12.3.1

     

    I am growing old and feeble minded. I often add kMDItemKeywords to jog my memory and speed up app searches based on function. E.g. there's a useful app called OmniDiskSweeper to find out what's eating your disk space.

     

    I use osxmetadata to add 3 Spotlight keywords: [ 'disk', 'space', 'analyze' ] to aid finding this app when I need it:

    image.thumb.png.3de19cbfe09922393311ccefdb00de83.png

     

    It works when I type "disk space" in Spotlight:

    image.thumb.png.42079b1dd605bd6fa803ccaaa08156c5.png

     

    also when I use mdfind from Terminal:

    image.thumb.png.81147c3a9fe51b1c12173723619efb78.png

     

    but not from Alfred:

    image.thumb.png.a000684c5462706eeebbe36be9932c51.png

     

    unless I put a literal comma (,)

    image.thumb.png.7db20acd293f12df64e1fd730fad5594.png

     

    But not in the reverse order:

    image.thumb.png.5079b58211dbcfb1f8ea904921365a0b.png

     

    Here are my prefs:

    image.thumb.png.c16d243728168408f525d72fd2d41fdb.png

     

    Is this a bug or just a limitation that can't be worked around?

    thank you

     

     

  1. Thanks @deanishe - sure of course

     

    I think I chose a bad example keyword ("limit")—probably should have used "window_height" or something. The idea is not to truncate or change the results at all, but merely to control the height of Alfred's window to show fewer or more results at one time. So altering the list prior to outputting JSON would not be the same thing.

     

    I have a workflow that displays news articles from a feed, and for example I'd like to show 20 articles in Alfred before I have to scroll. It's currently not possible since there's a max limit of 9 in the GUI.

     

    Even if it allowed me to set the height to 20, I would not want this in most cases. But for a couple of workflows it would be useful to have. Hope that explains it better?

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

    image.thumb.png.6a1875069cce21a5e6e930436e7ecc19.png

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

     

    image.thumb.png.795bc2430fd5e2da74b94d9dea2051a9.png

  4. 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": [
        ...
      ]
    }

     

  5. 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)
    

     

  6. 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?

     

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

    • 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

     

    screen.thumb.png.d1c7044c90949b0c210ff454844a7f12.png

×
×
  • Create New...