Zrajm’s programs and hacks

These are some of my numerous small programs. As times go on by I’ll probably add more of them to this page. I used to be a Gentoo user, but I changed to Ubuntu many years ago (circa 2008). Some of these programs may thus still come with a Gentoo Portage ebuild, but, if so, it most likely haven’t been updated since my Gentoo days (YMMV). Feedback of any kind would be most appreciated (write to zrajm@klingonska.org).

If you’re interested in my by far most ambitious project, the Klingonska Akademien website, then you can browse or checkout the sources at git.klingonska.org (the site’s GitHub repository). – If you just want to have a look at the site (and check out the awesomeness of the Klingon language), then go directly to klingonska.org.

binratd binratd is a small daemon, which allows the user to quickly and exactly move the mouse pointer using the keyboard (or commands). It works by splitting the screen into four equally-sized quadrants placing the pointer in the middle. User chooses one of the quadrants, which moves the mouse pointer there, and splits that into four subquadrants. The process is repeated until mouse pointer is located where user wants it (typically 2-6 keypresses required to hit the exact right spot, depending on spot size and placement; 12 keypresses gives you 1 pixel precision on a 1024x768 screen). Requires Perl and CPAN module X11::GUITest to work.
Log::Parse Log::Parse is a Perl module for parsing logfiles. It can handle multiple-line log entries, can resume reading where a previous instance left off (esp. useful on files which continuously grow) and has a callback function for transparent extraction of date/time (or other data) from the header of each log entry. Reading of files is done in chunks for better performance.
     A regex is used to match the beginning of the log entries, and all parenthesized subexpressions in the regex are passed on to the callback function, which in turn may do any processing wanted. Callback result is returned with each read() (in list context) together with the read log entry, making your log-parsing loop exceedingly simple, no matter how complex your log format may be. Requires Perl to work.
irssi-scripts These are a few plugin scripts for Irssi that have written and use: debuggy.pl—don’t remember what this does; fifo_remote.pl—a “remote control” which lets you send Irssi commands through a named pipe; ratified.pl—for Ratpoison users, displays specified incoming messages in the ratpoison status bar;xcuses.pl—define any number of aliases for changing away status, each with its own message, e.g. /zz for “away sleeping” and /work for an “away at work”; zz—shell command to change call the /zz command in Irssi, symlink to zz to call any other command. All scripts requires Irssi to work; zz additionally requires the fifo_remote.pl and xcuses.pl scripts here included.
mplayer-lastfm Mplayer-lastfm is a wrapper script; it starts mplayer (and passes along command line arguments) and then stays around and parses mplayer’s terminal output, to find out which files are being played. Played files are examined for audio tags, and, if found, these are scrobbled to last.fm (account info is stored in a small config file). Requires Perl, mplayer and taginfo to work.
ogglink Ogglink is a command line tool. It creates links to directories containing music—assuming that each directory contains only one album—and names the resulting link according to any tags found in the music files. That is, as long as your music files are decently tagged, and organised one album per directory, the links will be systematically named, regardless of the naming scheme of the music files.
     I use this to create a homogenous list of music for my jukebox system, while still retaining the original file names—useful, for example, to be able to continue seeding a music torrent. Requires Perl and taginfo to work.
outwrap Outwrap is a simple output wrapper for cronjobs. It can redirect the output of (any) specified command to one or more email addresses, and it can be used to suppress output on successful execution (emailing the complete output of the cronjob only if it fails with exit status other than zero). It also always includes the exit code of the cronjob it its output. Requires a POSIX-compatible “/bin/sh” (e.g. dash, but please don’t use bash as “/bin/sh”), and a an MTA which provides the “sendmail” binary (e.g. postfix or exim).
phoned Phoned is a small daemon for logging time and caller ID information of incoming phone calls. It requires a modem with caller ID detection.—Logging is done using the system logger.
     The program is written in Perl, and is primarily written to fullfill my own needs. That means you’ll probably have to re-write something to get it to work for you, unless you (like me) live in Sweden, and use ratpoison. Also included is a script for use with metalog, which beeps and displays the calling number on screen when a call is received. (Changes and ideas are welcome, also, maybe someday I’ll re-write this program C.)
ratmen Ratmen is a simple program for displaying a menu in a window. On selection is may either run a program or simply write something on standard out. It is inspired by, and is similar in function to, 9menu and ratmenu but is muchly improved. It includes: User settings in X resources, long and short option names (using getopts), scrollable menus (if they do not fit on screen), both mouse and keyboard support, exiting on unfocus, and a decent manpage.
termmen Termmen is written in zsh, and aims to do what Ratmen does, except entirely inside the terminal. The menu can’t be navigated using the mouse, but instead has several less-inspired keybindings for navigation. The menu is displayed on standard error, using ANSI terminal escape codes, and user selections are outputted on stardard out for a calling script to read. Easily invoked in scripts, e.g. using REPLY="$(termmen Yes y No n)" (REPLY is then set to y/n depending on whether user chose "Yes" or "No" on menu.) Requires zsh to work.
Term::ProgressMeter A Perl module for outputting a progress meter on the terminal. It’s invoked at user-specified intervall, and you pass it references to a couple of variables which it is then free to inspect. The progress meter is then automatically updated at the given interval, with no additional trouble for the programmer. Kinda neat. Beta. It is quite similar to the Term::ProgressBar (by Martyn J. Pearce, available from CPAN), except that I wanted to be able to mix the progress bar with normal output freely (this is almost totally transparent with Term::ProgressMeter. Requires Perl to work.
Zimplex Zimplex my attempt at making Opera’s UI bearable. A very non-fancy skin, made with only simplicity of design, clarity of use, and minimal screen usage in mind. It’s based on Simple, with tab colours from Cimple. As soon as I get around to doing it, I’ll redo the reload button to be more of a classic one—maybe more like the one in Dimple—the current one is an unintuitive yin-yangy-thingy. The skin is sorta half-finished, but usable (not all icons have been “unrounded”—some still retain the look from Simple—I’ll get back to that). Requires Opera to work.