Monday, October 5, 2009

Readability bookmarklet, browsers and StumpWM

Recently, I was looking for a way to get rid of the web-design while surfing the Net. Some most obvious ways, like banning custom fonts in Firefox work nice, while banning custom colors makes reading Gmail and Google Reader extremely unpleasant.

In Firefox I use TidyRead extension regularly. In the rare cases when TidyRead fails to do its job in the way I expect it to do, I use Readability bookmarklet. Readability, though, has a huge deficiency of being a bookmarklet. I mean, to use it you have to grab the mouse and click it. Of course, one could use keyboard to select Bookmarks menu and press twenty four arrows to get to the bookmarklet, but, of course, this is not what I would like to see. Especially because I love StumpWM window manager which is known for the disregard of mouse-like pointers. I needed a way to call the bookmark from the keyboard.

Here's what I came up with. Below is a piece of my .stumpwmrc file:

(defcommand readability () ()
  (send-meta-key (current-screen) (kbd "C-l"))
  (window-send-string "javascript:(function(){readStyle='style-novel';readSize='size-medium';
  (send-meta-key (current-screen) (kbd "RET")))
  (define-key *top-map* (kbd "s-p") "readability")

NB! I had to split the long line into a number of shorter ones. Merge them together to make the command work!

The first lines defines a new command which behaves just like you would: "presses" C-l to move the pointer to the address bar of the browser, pastes the full text of the bookmarklet and presses Return. That's it! And the last line maps the new command to a keyboard shortcut super-p.

No comments:

Post a Comment