(jm: I'm hoping someone will come up with vim support ;)
(updated 4 Mar 2005: updated clipboard version to "copy" instead of "cut")
Jef Raskin wrote
All that is really needed on computers is a "Calculate" button or
omnipresent menu command that allows you to take an arithmetic
expression, like 248.93 / 375, select it, and do the calculation
whether in the word processor, communications package, drawing or
presentation application or just at the desktop level.
Fortunately, there's a blue "Access IBM" button on this keyboard that
doesn't do anything. So, I configured tpb to make "Access IBM" do this:
perl -e 'print eval `xsel -o`' | \
xsel -i && xte 'key Delete' 'mouseclick 2'
(That is, get the contents of the X primary selection, run it through a
Perl "eval", put the result back into the X primary selection, then fake a
delete and paste.)
Here's a version that uses the X clipboard selection instead.
xte 'keydown Control_L' 'key c' 'keyup Control_L' && \
perl -e 'print eval `xsel -b -o`' | xsel -b -i && \
xte 'keydown Control_L' 'key v' 'keyup Control_L'
This one seems to work better in gedit.
So, say you're filling out a web form and you want to buy sqrt(9) pcHDTV
cards. All you have to do is fill in the expression, select it, and press
"Access IBM". Yippee! One, two, three units of soon-to-be-illegal,
better-buy-them-now freedom-compatible hardware.
If you want to do this, besides tpb, you'll need xsel and xte, which is
part of xautomation. If you don't have an unused button, you could also
set up a binding in your window manager or build a big red outboard USB
"eval" button or something.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!