zsteir Posted June 3, 2016 Posted June 3, 2016 (edited) 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? Thanks. Edited June 3, 2016 by zsteir
deanishe Posted June 4, 2016 Posted June 4, 2016 (edited) 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 December 27, 2018 by deanishe Fix link
zsteir Posted June 4, 2016 Author Posted June 4, 2016 (edited) 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... </EDIT> _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> <quicklookurl>https://www.alfredapp.com/</quicklookurl> <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> </item> 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: wf.add_item(**item) wf.send_feedback() 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 June 4, 2016 by zsteir
deanishe Posted June 4, 2016 Posted June 4, 2016 This can't be done using Alfred-Workflow's feedback mechanism. It doesn't currently support Alfred 3's mods. Generating JSON is much easier than XML, in any case, so it's not a big problem.
zsteir Posted June 4, 2016 Author Posted June 4, 2016 Thanks. Just to be clear: the feedback mechanism will work if I change the output to JSON?
deanishe Posted June 4, 2016 Posted June 4, 2016 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), } items.append(item) # Other items ... ... # Send to Alfred json.dump({'items': items}, sys.stdout)
evanfuchs Posted December 27, 2018 Posted December 27, 2018 On 6/4/2016 at 2:00 AM, deanishe said: It's hard to explain in text. This demo workflow shows what I mean. 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?
deanishe Posted December 27, 2018 Posted December 27, 2018 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.
deanishe Posted December 27, 2018 Posted December 27, 2018 Also, please bear in mind that the workflow is old. You wouldn't use the same JSON today. You don't need to smush everything into arg any more: mod can have a variables member now.
nikivi Posted December 27, 2018 Posted December 27, 2018 (edited) 2 hours ago, deanishe said: Here's the workflow. 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 December 27, 2018 by nikivi
deanishe Posted December 27, 2018 Posted December 27, 2018 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.) nikivi 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now