April 2007 Archives

An astronomical mistake

| No Comments

The wonderful “The Peace War” by Vernor Vinge has the following passage:

Jupiter and Venus blazed like lanterns, and the stars were out.

According to the book, this happens one day in April 2048, right after sunset.

The trouble is, xephem says that in April 2048 Venus is the morning star!

Am I being mean, or what?

Some time ago I’ve got two monitors connected to my workstation at work. I do not like using Xinerama, so I have, in X11 terminology, two screens, :0.0 and :0.1.

It bugged me that I had to move the mouse cursor to switch between the screens. There must be a way to do it with keyboard, I thought. Some googling revealed a wiki page about dual monitors setup, which had a reference to a little C program, dualmouse.c by David Antliff.

It worked fine if all I wanted to do was to switch from my current screen to “the other one”. But I also wanted to be able to do things like “switch to workplace 4 on screen 0”, and the program could not be used for that.

Fortunately, the wmctrl utility could do things like “switch to workplace 4 on the current screen”, so all I had to do is to modify the dualmouse.c program to support “switch to screen N” functionality, and the rest is, as they say, shell (or Perl) scripting.

The ~/.fluxbox/keys file (if you are using something else than fluxbox, you are on your own here) would have things like:

Control F1 :Exec flux2workspace 0 1
Control F2 :Exec flux2workspace 0 2
Control F3 :Exec flux2workspace 0 3
Control F4 :Exec flux2workspace 0 4

Control Shift F1 :Exec flux2workspace 1 1
Control Shift F2 :Exec flux2workspace 1 2
Control Shift F3 :Exec flux2workspace 1 3
Control Shift F4 :Exec flux2workspace 1 4

And the flux2workspace script looks like this:

#! /usr/bin/perl -w
exit unless @ARGV == 2;
system("dualmouse $ARGV[0]");
$ARGV[1]--;
$ENV{DISPLAY} = ":0.$ARGV[0]";
system("wmctrl -s $ARGV[1]");

Next time: accomplishing the same feat with x2x-controlled displays.

cd to a directory of a file

| 3 Comments

In zsh, define the following function:

cd-()
{
    local dir
    cd `dirname $1`
}

Then this:

cd- /usr/ports/www/linux-opera/Makefile

changes directory to /usr/ports/www/linux-opera/.

Trivial pleasure, but pleasure nevertheless.

About this Archive

This page is an archive of entries from April 2007 listed from newest to oldest.

February 2007 is the previous archive.

July 2007 is the next archive.

Find recent content on the main index or look in the archives to find all content.