Jump to content

caobo

Member
  • Posts

    3
  • Joined

  • Last visited

Reputation Activity

  1. Like
    caobo reacted to Mr Pennyworth in [WIP, POC] Spotlight like rich preview pane for alfred workflows   
    Link to better quality videos
    Download the code and play around: https://github.com/mr-pennyworth/alfred-extra-pane

     
    Q: What is it?
    A: An app that workflow creators can add to their script filters
     
    Q: What does it do?
    A: It renders html from quicklookurl of every item in the json.
     
    Q: How does it do it?
    A: By intercepting the json and by monitoring up-arrow and down-arrow keypresses.
     
    Q: How to add it to a workflow?
    A: By adding it to the script filter. Here's an example (from the workflow in the above GIF): notice how everything remains the same, just that at the very end, json needs to be piped through the helper app
    # Before: query=$1 PATH=/usr/local/bin:$PATH items=$(curl 'http://127.0.0.1:7700/indexes/dictionary/search' --data "{ \"q\": \"$query\" }" | jq '.hits') echo "{ \"items\": $items }" # After: query=$1 PATH=/usr/local/bin:$PATH items=$(curl 'http://127.0.0.1:7700/indexes/dictionary/search' --data "{ \"q\": \"$query\" }" | jq '.hits') echo "{ \"items\": $items }" | 'AlfredExtraPane.app/Contents/Resources/scripts/alfred-extra-pane'  
    Q: Sounds great! Now tell me everything that's not working!
    A: This is more of a proof-of-concept and very rough around the edges.
    Things that are easily doable, but haven't been done yet (contributions welcome! ) change appearance automatically based on alfred's theme make other things configurable like dimensions Things that seem doable, but quite difficult with my knowledge of macOS GUI programming (which is about a week) let alfred remain horizontally-centered when the pane is not present, and when the pane appears, make the "alfred+pane" combination horizontally-centered (by moving both the pane and alfred window to left) Things that seem doable, but require guessing about alfred's inner workings: as @deanishe points out, alfred builds "uid-based-knowledge". that means if the returned json has an uid field, alfed can use that later to re-order items while displaying based on whether of them were previously actioned on. the knowledge is an sqlite database, so that's the easy part. the not-trivial part is to figure out how alfred sorts the items. Workaround: if you want to use this tool in your workflow, don't add UIDs to your json. One perfect use case for this is the dictionary workflow in the GIF. You looking up a word in the dictionary is a very weak signal that the word is important (many times, it is actually a signal that it is now less likely that the word will be looked up) This is a GUESS based on LIMITED observation. sorting is based on 1) how many times an item has been actioned (freq) 2) latest timestamp of action (timestamp) primarily sorted based on freq, ties are broken by timestamp special case: if the script filter has executed without an argument, and one of the resultant items has an entry in the latching table, the item goes to the top, irrespective of the above sorting. The above algorithm has been implemented and seems to match alfred's sorting.
    Things that seem impossible to me: take into account mouse scroll interactions. right now, when selected row changes because of a mouse hover, the pane doesn't update, and will continue to show the old preview. As mouse hovers over various rows, the pane updates correctly, as long as Alfred's results have not been scrolled using mouse.  
     
×
×
  • Create New...