> mostly stupid bash tricks_ 

c u t u p @ c u t u p . o r g

 xml 

[firefox applescript slide] last modified: 03/25/2007 02:03 pm

I wanted to like Deskbrowse but the whole time I use it I'm missing the little things I get in my main browser, like remembering urls, and hotkeys for bookmarks, working find in page, and, well, basically everything. But I love the sliding drawer - it really works for me.

There's an applescript floating around for Safari that makes it slide in and out real nice, but I am good and hooked on Firefox, and that applescript doesn't work on it - I think because it's not a Cocoa application. So I hacked together my own applescript that seems to work pretty well with Firefox. It's ugly but it works. It will toggle the window to slide in and out, or open a new window if firefox isn't running or has no window open.

Save the script to your drive, open it with script editor and set your screen width and homepage, save it as a .scpt somewhere, then assign a hotkey to run it (with quicksilver or butler or something) and enjoy slidey goodness with your favorite browser.

Please leave a comment about any bugs, or if you have suggestions for improvement. Right now the script only deals with one window, and I don't like the code that deals with when firefox is running with no window open. For the next version I'd like to eliminate the need to set a homepage and screen size.




[firefox api] last modified: 03/25/2007 02:03 pm

Lately, I've been customizing the heck out of my Firefox bookmarks. I thought I'd write about what I've been doing. It's a couple sort of trivial things, but taken together it's been pretty darn uselful, and none of this stuff was as immediately obvious to me as maybe it should have been.

Since I use del.icio.us almost none of my bookmarks are just plain urls, they are mostly hacks of Firefox's Quick Search feature. I use the Bookmarks Synchronizer extension to publish a copy of my bookmarks online, so as well as having a backup I have a way to standardize changes across machines, which makes it feel more worthwhile to spend time on this.

Here's the deal. If you make a new bookmark in Firefox you get this:

add_bookmark.jpg

What's important are the location and keyword fields.

To make a custom search bookmarklet, you perform the search you want and copy the resulting url. For example, if I go to altavista and search for poop, I end up at this url:

http://www.altavista.com/web/results?itag=ody&q=poop&kgs=1&kls=0

Now, if I make a bookmark to that url, with Title altavista, replace poop in the url with %s and make that the Location, and set the Keyword as alta, entering alta 31d1 will search for 31d1 in altavista. So you see, that %s gets replaced with everything after the keyword. Note that just entering alta into the url bar will search altavista for %s.

Where it starts to get interesting is how this can interact with any script.

What I do is have (some of) my (php) scripts accept the full $_ENV['QUERY_STRING'], parse the string, and perform whatever actions. For example, a todo list script might take:

http://url\_to\_script/?-17

as "delete item 17",

http://url\_to\_script/?blah blah blah

as "add new item 'blah blah blah', and of course

http://url\_to\_script/

should display the list. To make our Firefox bookmark extra nice we make it so

http://url\_to\_script/?%s

redirects to http://url\_to\_script.

Then i can make my bookmark Location http://url\_to\_script/?%s and set a keyword, and my browser is a little closer to a command line.

With a little javascript we can get a little deeper into browser as command line stuff. The excellent del.icio.us super-fast bookmarklet is a case in point. It allows you to post a page to your del.icio.us by typing keyword tag1 tag2 ... tagx into the url bar while you are on the page, also it puts any highlighted text into the extended field. Unfortunately, typing the keyword with no tags posts the page to del.icio.us under the tag %s, and I don't know enough javascript to fix that. My feeling is that the bare keyword should just take you to your del.icio.us page, or do nothing.

What I like about making scripts to fit this style is that the logic is all server side, and there are many ways to access and alter the data. You have nice command line style bookmarks, you still have the regular url you can access from any browser, and it is almost trivially easy to write a bash script using lynx -dump or curl -s to access and alter the data through a terminal. This is what I do with my todo list. I access it through a bash script all the time, and the script contains barely any logic.

The drawback for the bash script is, of course, it only works when I'm online. I'm still experimenting with different ways of keeping and synching a local copy, but that's not really the point of this post.

The upshot is i have a ton of bookmarks that i access through keywords instead of urls, and many of them can take arguments. For example, I search del.icio.us now with a bookmark with Location: http://del.icio.us/tag/%s and Keyword: ds. Since del.icio.us expects tags to be separated by + signs, to search for audio and mp3 I'd enter ds audio+mp3.

Sites where the url structure is the API lend themselves to this so well, the whole thing gives me lots of ideas. I feel like making web-based scripts with an eye to hooking into this functionality of Firefox is an easy way to get a lot of extras for free.




[conkeror keyboard browser firefox] last modified: 03/25/2007 02:02 pm

conkeror is pretty neat. An extension that turns Firefox into a fully keyboard mode browser. It's totally sketchy, but it works ok on my no-room-for-a-mouse linux box. The documentation and bindings list is only available in-browser, and I forgot the key to find the help screens for a while (C-h i, C-h b), and that there is a paucity of documentation becomes clear when the only place I could find some was in cvs.

It's totally emacs, but there's an (undocumented-exept-for-existence) vi mode (for the heathens). And a .conkerorrc file that doesn't seem to actually work. So on the list is:

  1. document the vi bindings out of that .js file in cvs
  2. hope it's being developed more
  3. figure out the .rc file



[All Posts] [top]

tags:

api
applescript
browser
conkeror
firefox
keyboard
slide