miq Posted October 23, 2013 Share Posted October 23, 2013 OK, thank you very much for your help anyway! Same results with both Mountain Lion and Mavericks. Link to comment
miq Posted October 23, 2013 Share Posted October 23, 2013 Update: It it working now. You were right, it just takes about 10 seconds to display the results (I have 877 .bdskcache files though). You helped me anyway as I had to get the cache files first. Thank you! Link to comment
schoeps Posted November 3, 2013 Author Share Posted November 3, 2013 I have updated the workflow to version 2.0; prior versions were very slow under Mac OS 10.9. It should be much faster now (be aware: searching becomes slower with each keyword). Please report any problems! Link to comment
jay-squared Posted February 9, 2014 Share Posted February 9, 2014 Sebastian, thank you for a great workflow. I have one feature suggestion - obviously, since I am unable to estimate how difficult this would be to implement, this is a mere suggestion. It would be great if one could set a default BibDesk template and then have one additional modifier which - provided the bib fiel containing the publication is open - copies the selected publication formatted according to the preset template to the clipboard. In essence, it would implement Bibdesk's "Copy using template" with a preset template. I am suggesting this because I often write short texts outside of LaTeX where I still cite publications I keep in Bibdesk. For what it's worth, I know it is possible to access the Bibdesk templates in AppleScript (which seems to break rich text) like this: tell application "BibDesk" set theTemplate to "OxfordLegal" set theDocument to document 1 set thePublications to the selection of document 1 tell theDocument to set the clipboard to (templated text using theTemplate for thePublications) end tell Link to comment
schoeps Posted February 16, 2014 Author Share Posted February 16, 2014 (edited) Sebastian, thank you for a great workflow. I have one feature suggestion - obviously, since I am unable to estimate how difficult this would be to implement, this is a mere suggestion. It would be great if one could set a default BibDesk template and then have one additional modifier which - provided the bib fiel containing the publication is open - copies the selected publication formatted according to the preset template to the clipboard. In essence, it would implement Bibdesk's "Copy using template" with a preset template. Great idea. I have set up a beta version. I hope that I have introduced no new bugs: https://bitbucket.org/schoeps/alfred/downloads/BibDesk_Search_beta.alfredworkflow If you press [CTRL]+[Enter] Alfred copies the publication string to the clipboard. I use the Bibdesk template "abbrvTemplate" for now but this can be changed easily. Please give feedback. Edited February 16, 2014 by Sebastian Link to comment
jay-squared Posted February 16, 2014 Share Posted February 16, 2014 (edited) Sebastian, thanks. It works great so far. As expected, the copying does not preserve the formatting, but that is a limitation of AppleScript itself and doesn't bother me as I use character style templates in my documents anyways. I have made one minor modification. I added tell application "System Events" set activeApp to name of first application process whose frontmost is true set process_bid to get the bundle identifier of process activeApp set activeApp to file of (application processes where bundle identifier is process_bid) set activeApp to activeApp as string end tell at the very beginning and changed the end of the script to tell application activeApp to activate return theResult As you can see, I also changed the name of the result from result to theResult - for some reason, it wouldnt't work otherwise with my changes. The idea behind these changes was to re-activate the formerly frontmost app after the clipboard was set. The activeApp part is somewhat complex to account for users who have different apps with the same name (I do because of Parallels). Cheers, Jan Jakob Edited February 16, 2014 by jay-squared Link to comment
schoeps Posted February 17, 2014 Author Share Posted February 17, 2014 (edited) As expected, the copying does not preserve the formatting, but that is a limitation of AppleScript itself and doesn't bother me as I use character style templates in my documents anyways. I have made one minor modification. I added ... As you can see, I also changed the name of the result from result to theResult - for some reason, it wouldnt't work otherwise with my changes. The idea behind these changes was to re-activate the formerly frontmost app after the clipboard was set. The activeApp part is somewhat complex to account for users who have different apps with the same name (I do because of Parallels). I have played around with templated rich text in the applescript to preserve formatting but this seems not to work. However, I added your changes to "Beta 2": BibDesk_Search_beta2.alfredworkflow. Thanks! I will use this version a few more days and then update the main download link. Edited February 17, 2014 by Sebastian Link to comment
schoeps Posted March 25, 2014 Author Share Posted March 25, 2014 (edited) I have changed the latest workflow from beta to an official version 2.1: BibDesk_Search.alfredworkflow . Edited March 25, 2014 by Sebastian Link to comment
Dellu Posted April 17, 2014 Share Posted April 17, 2014 Sorry, I am new to Alfred. I don't get how the modifier keys work. What I am looking for is to get be able to copy just the citetation key of the associated reference and paste it to my document. I am able to search the references. I am getting results. But, I don't understand how can I copy just the citation key. Can sb explain please? Link to comment
Dellu Posted April 17, 2014 Share Posted April 17, 2014 I am getting a result like /Users/~/Library/Caches/Metadata/edu.ucsd.cs.mmccrack.bibdesk/Yimam2006.bdskcache when I try to copy Link to comment
schoeps Posted April 18, 2014 Author Share Posted April 18, 2014 I am getting a result like /Users/~/Library/Caches/Metadata/edu.ucsd.cs.mmccrack.bibdesk/Yimam2006.bdskcache when I try to copy There is a readme for each workflow, you can access it by double-clicking on the workflow icon within Alfred's preferences. Your question is hopefully answered there: BibDesk Search (Version 2.1) This workflow allows to search your Bibdesk library. It relies on Spotlight and Bibdesk, i.e., it finds only entries that are cached in the directory "~/Library/Caches/Metadata/edu.ucsd.cs.mmccrack.bibdesk/" You can use the following actions: - [return] to open in Bibdesk - [cmd]+[return] to copy the citekey to clipboard - [shift]+[return] to open an attached pdf in your favorite viewer - [alt]+[return] to copy a citation string ("abbrvTemplate") The artwork is property of BibDesk.app (http://bibdesk.sourceforge.net) which is published under the BSD License. Link to comment
dfay Posted April 23, 2014 Share Posted April 23, 2014 The readme doesn't actually match the commands in the workflow. The actual commands are, if I read correctly: - [return] to open in Bibdesk - [ctrl]+[return] to copy the citation to the clipboard - [alt]+[return] to open an attached pdf in your favorite viewer - [shift]+[return] to copy a citation string ("abbrvTemplate") - [command]+[return] to reveal linked file in Finder But at this point, besides return, only alt-return and shift-return work - these both rely on bash scripts. The other two rely on Applescripts which don't work on my machine. Link to comment
walton Posted April 30, 2014 Share Posted April 30, 2014 I am loving this workflow with the exception of problems running some of the sub-commands (like @dfay). ^↩ says it will copy a citation to clipboard, but returns the following Applescript error in the Alfred debugger: NSAppleScriptErrorAppName = BibDesk; NSAppleScriptErrorBriefMessage = "An error of type 6 has occurred."; NSAppleScriptErrorMessage = "BibDesk got an error: An error of type 6 has occurred."; NSAppleScriptErrorNumber = 6; NSAppleScriptErrorRange = "NSRange: {802, 47}"; ⌘↩ is supposed to reveal the PDF in Finder, but instead spits out this Applescript error: NSAppleScriptErrorAppName = Finder; NSAppleScriptErrorBriefMessage = "Handler can\U2019t handle objects of this class."; NSAppleScriptErrorMessage = "Finder got an error: Handler can\U2019t handle objects of this class."; NSAppleScriptErrorNumber = "-10010"; NSAppleScriptErrorRange = "NSRange: {165, 14}"; All other commands work as expected. Any ideas? Link to comment
schoeps Posted April 30, 2014 Author Share Posted April 30, 2014 (edited) As you may have guessed, the scripts are working fine on my computer. Thus we have to debug it together... I have uploaded a debug build here: BibDesk_Search_debug.alfredworkflow It should show dialogs with the path to the entry selected in Alfred. Let's have a look at the more difficult case, i.e., what happens if you press ^↩. For this we analyze the Applescript.Can you copy the following into the Applescript editor and adapt q to contain the path to your bdskfile? What happens if you run it? set q to "/Users/????/Library/Caches/Metadata/edu.ucsd.cs.mmccrack.bibdesk/????.bdskcache" --remember active app tell application "System Events" set activeApp to name of first application process whose frontmost is true set process_bid to get the bundle identifier of process activeApp set activeApp to file of (application processes where bundle identifier is process_bid) set activeApp to activeApp as string end tell -- check whether BibDesk is ready tell application "BibDesk" activate if (count of documents) = 0 then beep display dialog "Please open your BibDesk database" buttons {"OK"} default button 1 return end if end tell tell document 1 of application "BibDesk" set bibkey to do shell script "mdls -name net_sourceforge_bibdesk_citekey '" & q & "'| cut -d'\"' -f 2" set thePub to get publications whose cite key is bibkey set theResult to (templated text using "abbrvTemplate" for thePub) end tell tell application activeApp to activate return theResult Edited April 30, 2014 by Sebastian Link to comment
dfay Posted May 2, 2014 Share Posted May 2, 2014 (edited) The path isn't the issue. The error message in the copy to clipboard script is because there's a hard-coded template name "abbrvTemplate" which isn't one of the BibDesk defaults. set theResult to (templated text using "abbrvTemplate" for thePub) When I change that to a text template (Jim Harrison's "plainTemplateNonNumbered" that comes with CiteInPages) that I have installed on my machine it works. Not sure what's up with the reveal in Finder script. Edited May 2, 2014 by dfay Link to comment
schoeps Posted May 2, 2014 Author Share Posted May 2, 2014 The path isn't the issue. The error message in the copy to clipboard script is because there's a hard-coded template name "abbrvTemplate" which isn't one of the BibDesk defaults. Thanks! I have created a new beta version (BibDesk_Search_beta.alfredworkflow) that now includes its own Bibdesk template. Can you please try it? I have also corrected the readme: You can use the following actions: - [return] to open in Bibdesk - [cmd]+[return] to reveal attached pdf in finder - [alt]+[return] to open attached pdf in your favorite viewer - [shift]+[return] to copy the citekey to clipboard - [ctrl]+[return] to copy a citation string Link to comment
dfay Posted May 5, 2014 Share Posted May 5, 2014 Hmm...I installed this and now Alfred displays the message Incompatible Workflow This workflow was created with a newer version of Alfred Please upgrade Alfred to the latest version (or pre-release) to use this workflow I am running Alfred 2.2 b243 which is the newest....I can't find a link to download a newer Alfred beta. The old version seems to be active, though, or the new one has issues - return, shift and alt options work; cmd and ctrl don't. Link to comment
smarg19 Posted May 5, 2014 Share Posted May 5, 2014 If you select "Automatically check for pre-releases" in the Alfred Update pane, you will be able to update to version 2.3 (264), which is the most up-to-date-version. Tho, it is, as the selection would suggest, a pre-release beta. Link to comment
schoeps Posted May 5, 2014 Author Share Posted May 5, 2014 Hmm...I installed this and now Alfred displays the message Incompatible Workflow This workflow was created with a newer version of Alfred Please upgrade Alfred to the latest version (or pre-release) to use this workflow I am running Alfred 2.2 b243 which is the newest....I can't find a link to download a newer Alfred beta. The old version seems to be active, though, or the new one has issues - return, shift and alt options work; cmd and ctrl don't. Can you try the workflow with the latest pre-release alfred? Thanks! Link to comment
dfay Posted May 6, 2014 Share Posted May 6, 2014 (edited) Thanks - I have the latest pre-release. Here's what I see - [return] to open in Bibdesk works fine, but the debugger displays a message: [ERROR: alfred.workflow.input.scriptfilter] Code 1: Exited with error code but no message - [cmd]+[return] to reveal attached pdf in finder doesn't work, debugger says [ERROR: alfred.workflow.action.applescript] { NSAppleScriptErrorAppName = Finder; NSAppleScriptErrorBriefMessage = "Handler can\U2019t handle objects of this class."; NSAppleScriptErrorMessage = "Finder got an error: Handler can\U2019t handle objects of this class."; NSAppleScriptErrorNumber = "-10010"; NSAppleScriptErrorRange = "NSRange: {230, 14}"; } - [alt]+[return] to open attached pdf in your favorite viewer works fine, but the debugger displays a message: [ERROR: alfred.workflow.input.scriptfilter] Code 1: Exited with error code but no message - [shift]+[return] to copy the citekey to clipboard works fine, but the debugger displays a message: [ERROR: alfred.workflow.input.scriptfilter] Code 1: Exited with error code but no message - [ctrl]+[return] to copy a citation string works fine, but the debugger displays a message: [ERROR: alfred.workflow.input.scriptfilter] Code 1: Exited with error code but no message In fact, on trying this a few times, the Code 1 error message is coming before I hit any of the modifier keys. Which would make sense since it refers to the script filer. Edited May 6, 2014 by dfay Link to comment
dfay Posted May 6, 2014 Share Posted May 6, 2014 Also....if I uncomment the display dialog on line 5, cmd+return displays the correct file but the spaces are escaped with %20. in Applescript Editor, this works: set f to "Dragonfly:Users:somebody:Documents:unruh 2014 evidencing the resti.pdf" tell application "Finder" to reveal f but this set f to "Dragonfly:Users:somebody:Documents:unruh%202014%20evidencing%20the%20resti.pdf" tell application "Finder" to reveal f gives the same error message. Link to comment
schoeps Posted May 6, 2014 Author Share Posted May 6, 2014 set f to "Dragonfly:Users:somebody:Documents:unruh%202014%20evidencing%20the%20resti.pdf" tell application "Finder" to reveal f gives the same error message. That is good news! Now, we know that spaces in file names seem to be the bad guys (I would never have found this issue because I use the bibkeys as filenames). I will have look to it! dfay 1 Link to comment
smarg19 Posted May 8, 2014 Share Posted May 8, 2014 (edited) For those interested, I've just posted a new BibDesk workflow that borrows the same design of my Zotero workflow (ZotQuery) but works with BibDesk and .bib files. While Sebastian's workflow was an initial inspiration, I've gone a few new directions and added many different types of queries. I'd love to get some feedback. The workflow post is here stephen Edited May 8, 2014 by smarg19 Link to comment
schoeps Posted May 8, 2014 Author Share Posted May 8, 2014 (edited) That is good news! Now, we know that spaces in file names seem to be the bad guys (I would never have found this issue because I use the bibkeys as filenames). I will have look to it! Problem seems to be solved I had to convert from URL encoding. Now I use PHP for that set thePOSIXfile to do shell script "php -r \"echo rawurldecode('" & theURL & "');\"" Please test it: BibDesk_Search_beta.alfredworkflow Edited May 8, 2014 by Sebastian Link to comment
dfay Posted May 9, 2014 Share Posted May 9, 2014 I am getting the error intermittently still...some files with spaces work perfectly, others give the "Finder got an error: Handler can\U2019t handle objects of this class." message. I'm puzzled. I'll see if I can figure out what is making the difference. Thanks for all your work on this. Link to comment
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