Jump to content

Junction with modifiers

Recommended Posts

Hi all,

I've got a query to search BibDesk (based on BibQuery by Hackademic). See pic HERE. The topmost trigger "bb", can call some of the other trigger "ba" and "bt" (which I do using applescript). However, "bb", "ba", and "bt" share most of their actions. Right now, this results in a mess. But using a junction doesn't help, since it doesn't allow for modifier.


Is there anyway to create some sort of junction that allows for modifiers?



Edited by zsteir
Link to comment

A Junction will work if you use the mods object in your results to set modifier keys and a workflow variable, too, (e.g. action="search") and then have Filter objects before your Actions to determine whether they should run.
It's hard to explain in text. This demo workflow shows what I mean.

Edited by deanishe
Fix link
Link to comment

Hi Deanishe,

Sorry, but I wonder if you can help a bit more. I'm sorry for the newbie question. I am working with a python script that output an XML (using your Workflow library). It prepares a dictionary like this, where the values have been extracted previously from a text file, etc.


<EDIT>: after digging around a bit more, I suspect that I am using a Workflow library that is too old. I guess I need the V2 branch. I'll try to figure out how to add it...



 _dict = {'title': title,
          'uid': _arg, 
          'valid': True, 
          'arg': _arg,
          'subtitle': sub

After your previous suggestion, I found the example XML file for a script filter of this kind, which recommends using something like this:


<item uid="home" arg="~/" valid="NO" autocomplete="Home" type="file">
    <title>Home Folder</title>
    <icon type="fileicon">~/</icon>
    <subtitle>Home folder ~/</subtitle>
    <subtitle mod="fn">Subtext when fn is pressed</subtitle>
    <subtitle mod="ctrl">Subtext when ctrl is pressed</subtitle>
    <subtitle mod="alt">Subtext when alt is pressed</subtitle>
    <subtitle mod="cmd">Subtext when cmd is pressed</subtitle>
    <mod key="shift" subtitle="New subtext when shift is pressed" valid="yes" arg="shiftmod"/>
    <text type="copy">Text when copying</text>
    <text type="largetype">Text for LargeType</text>

But I can't seem to figure out to properly add additional items to _dict.


When I use, for example:


     _dict = {'title': title,
                    'uid': _arg, 
                    'valid': True, 
                    'arg': _arg,
                    'subtitle': sub,
                    'subtitle mod=\"cmd\"' : "whatever",

I get an error "unexpected keyword argument ". It is ultimately sent to Alfred like, this, with prep_res being the array of _dict(s), I think. What generates the error is the add_item.


for item in prep_res:


I'm sure I'm not constructing the dict properly, but I'm afraid I'm in over my head. The entire script is here: https://dl.dropboxusercontent.com/u/565419/bibquery.py.


Ideas? Many thanks.

Edited by zsteir
Link to comment

You just need to create a plain, old Python dictionary and turn that into JSON with json.dump(mydict, sys.stdout).
It has to be the right format, of course. What's perhaps not obvious is that you can't just set arg to another dictionary. You have to set it to a JSON string: 

items = []

# First item
arg = {'alfredworkflow':{'arg':'arg goes here', 'variables':{'var1':'value1', 'var2':'value2'}}}
item = {
    'title': 'Item One',
    'arg': json.dumps(arg),

# Other items
# Send to Alfred
json.dump({'items': items}, sys.stdout)
Link to comment
  • 2 years later...
12 minutes ago, evanfuchs said:

I know I'm digging up an old thread, but I"m trying to follow the instructions to use mods object and filter results. The link to the demo workflow is broken. Any chance of sharing it again?


Sorry. Dropbox broke everything, and there's no easy way to find all the broken links. Thanks for the heads-up.


Here's the workflow. I've also fixed the link above.

Link to comment
2 hours ago, deanishe said:


Sorry to hijack the thread. But I've been thinking of setting up my own service to share downloads to stuff off my own server. Can you share how you setup your workflow for it? I know your personal site is generated with Hugo and your downloads are links coming off your domain. 

Thank you.

Edited by nikivi
Link to comment
2 hours ago, nikivi said:

I know your personal site is generated with Hugo and your downloads are links coming off your domain


My domain and personal site are totally separate things. The former (deanishe.net) sits on a Linode and the latter (www.deanishe.net) is on GitHub Pages. I use GH Pages because it seamlessly integrates the gh-pages branch of your projects with the website.

Previously, I just dumped workflows like this one in a folder on my deanishe.net webserver (and before that in my Dropbox public folder, when it still worked).

I just recently decided it'd make more sense to put them on my website where I can add a bit of context, not least to remind me what the workflow does.


2 hours ago, nikivi said:

Can you share how you setup your workflow for it?


There isn't really a workflow. I don't do it often enough for it to be worth automating. Previously, I just used a ForkLift bookmark to open the relevant folder on my webserver. Now, I've written a Hugo template that shows a download link for any resource file that isn't an image. (Hugo resources are any files in the same directory as a post's index.md.)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...