Interfacing Acrobat Reader with Google Chrome
This is a small success story about making a small script to interface a stupid program with another that it should be able to talk to in the first place. I tried to configure my Adobe Reader in Linux to use Google Chrome to open ducument URLs, and to my chagrin, when I tried to open a link in a PDF document it opened Chrome with some stupid code in the URL bar. I then decided to make a script that Reader could call that would interpret its commands and then call Chrome appropriately.
With Firefox it works… What Reader does is to call firefox with “-remote openURL(http://example.com,new-tab)”. Lots of stupid bureaucracy, isn’t it? Why all that? It should just call the command with the damn URL as an argument!!!
This is how google-chrome works. If you call chrome with the URL it opens it up the way I want, with the page on a new tab. So all I needed was to strip all the stupid syntax, extract the URL and execute chrome with the URL as an argument.
To me, that’s the perfect work for a bash script with a perl one-liner. Here it is:
#!/bin/bash google-chrome `echo $2 | perl -wne $'print $1 if m/openURL\((.*),new-tab\)/'`
bash picks up the second argument sent by Reader, to skip the “-remote”, then perl finds the URL inside all the crazy and useless syntax and spits it out. Then bash executes chrome with it.
This is it. Knowing a little bit of bash, perl and regex can bring you some happiness when you are being a victim of a bad program.
About this entry
You’re currently reading “Interfacing Acrobat Reader with Google Chrome,” an entry on xor
- Published:
- 2011/03/05 / 13:21
- Category:
- regex, small scripts
- Tags:
1 Comment
Jump to comment form | comment rss [?] | trackback uri [?]