Posts for: #Lua

wmiirc in lua

I have been running wmii window manager for almost a year, and since the beginning I have been using the ruby wmiirc script.

In wmii all events are handled by the wmiirc script, while wmii handles the display of windows. The wmiirc should thus do nothing until a user event (or a program event) occurs. Well, it turns out that updating the clock and status widgets requires that a thread be ran to write the new text to the screen.

So far, that’s not so bad. We could schedule updates to occur infrequently. The bad part comes from the ruby implementation of threads. Threads in ruby 1.x seem to require that the interpreter do a busy wait at an interval of 10ms… this does not make me very happy as it chews up a ton of battery life according to powertop.

I wanted to rewrite a wmiirc in something else. That something else, I decided, would be [lua]{tag/lua}. I chose lua because of the small footprint, use of coroutines and iterators to avoid threading, and the fact that I can plug things in using C.

Read more →

ion3 greatness and acting on X selections

So it turns out that I have not blogged about [ion3]{tag/ion3} yet. I’ve been using ion3 as my window manager for about half a year, and I still love it. It’s fast, does not requrie a mouse for most tasks, and has very powerful scripting and keyboard binding capabilities. But enough about the greatness of ion3… and onto the rest of the story…

For some time I wanted to have a magic key binding that would do somethinganything – with my X selection. Say, I highlight a URL and push this magic key, it should display it in a new browser tab. If I highlight what looks to be a valid file, it should launch gvim on it, etc. I previously tried with sawfish, but I suffer from a serious condition that causes me to vomit when I look at lisp-like languages – one of the reasons I abandoned emacs years ago.

It was pretty easy in ion. Below is my [lua]{tag/lua} code to implement what I described…

Read more →