Dual Boot Magic

I dual boot on two out of three computers but I really only spend less than 1% of the time in Windows. Occasionally I do find the occasion to bring the red headed stepchild out of the basement. As if this weren’t annoying enough I would often reboot, lack the patience to babysit the reboot, and come back just in time to see that I missed the grub menu and now I have to reboot again. Well some time ago I found a solution to this mess. Enter grub-set-default <num>—this nifty command sets the grub entry to load by default for the next boot only. So I count my grub entries and put the proper number in a nifty reboot script. Alas, by the next time I use this script various Ubuntu updates have changed my grub menu such that now I get some old kernel instead of Windows like I wanted. This clearly wouldn’t do, so I fixed it. Now you can do the same.

Save the following to a script, such as ~/bin/windows.

#! /bin/bash
TARGET=windows
MENU=/boot/grub/menu.lst
ENTRY=$[`grep ^title $MENU | grep -n -i $TARGET | cut -d: -f1` - 1]
sudo umount /media/surfer
sudo grub-set-default $ENTRY
sudo reboot

The umount /media/surfer line just unmounts my network media, speeding up the reboot process working around an annoying Ubuntu bug where the shutdown hangs waiting for network drives even as the network is already down, hence no response from the share and a long timeout.

The ENTRY= line is the interesting part. First grep ^title grabs all the grub entries from which we will count the indexes. Next, grep -n $TARGET prints the line number of the entry we are interested in (Windows) along with the line. cut -d: -f1 splits the line on ‘:’ and returns the first field, the number we want to boot. Finally, grep counts from 1, but grub counts from 0, so $[<stuff> - 1] does bash math, wich is like normal math mostly, and hence we have the proper argument to give grub-set-default, et voila.

You can even put an icon in your panel or desktop that will run this script, giving you Windows in one easy click.

24 Dec 02:48 :: 0 comments :: Comment
Tags: linux, computers, annoyances, cool

CSApprox

Probably the coolest VIm plugin since netrw, welcome CSApprox! Just put this in your .vim/plugin and away you go with completely transparent and automatic 256 color themes for your terminal vim that look amazingly not unlike the GUI versions of those themes. Just make sure your terminal properly reports 256 colors, and that your vim binary is compiled with gui support (debian flavors do this, but apparently not red hat flavors). If either of these are missing it will give you a little message and delay opening vim, if this is a problem you might want to suppress that output.

I also highly recommend enabling 256 colors via Xresources rather than setting TERM=xterm-256color, this will save headache when sshing in from a less fine terminal or when logging in at the console. A quick google turns up plenty of info on how o set your Xresources with one caveat; if you use uxterm like any sane person would, you need s/Xterm/UXterm/. I’ve also found cases where I need xterm as well, so I simply put all three in there to be safe.


Xterm*termName: xterm-256color
UXterm*termName: xterm-256color
xterm*termName: xterm-256color

25 Nov 09:22 :: 2 comments :: Comment
Tags: linux, programming, computers, cool, vim, colors, terminal, xterm, uxterm, gvim, 256

Mutt Color Theme

Some time ago, being the no good visual designer I am, I decided to put together a mutt color theme. This was no ordinary theme, I’m talking 256 colors! No, don’t worry, the theme doesn’t use all 256 colors.

Aaron’s post prompted me to put up my theme for consumption, enjoyment, and comment. If you want details on how to make the colors work, follow the link above, he did a good job of that already.

Now, the theme and screenshots.

14 Nov 11:45 :: 4 comments :: Comment
Tags: linux, computers, mutt, cool, color, email, 256

White Spaces: Coming to a Technology Near You

In a refreshing break from political posts, I’m going to rejoice in the bounty that is white-space airwaves made free and open. With all TV broadcast going digital, there will be many chunks of EM spectrum between digital TV channels. This is known as white-space, or unused digital TV spectrum. The FCC voted 5-0 to make these unused frequencies available in the same sense CB, 802.11 and walkie talkie frequencies are. What does this mean? Why the big fuss? Well, not only does it mean more frequencies available for wireless internet and other uses, it also means longer range for wireless internet and other things. These are the same frequencies that TV signals are broadcast long distances on, remember. It is very exciting. Some call it wifi on steroids. Along those lines, think Digis (or insert wireless provider here) on steroids. Room for more wireless ISPs and at greater range, therefore less base stations, more customers, more competition, and lower costs all around! But it’s not just about wireless providers, or even just internet, my brother wants to build a GPS receiver that transmits the raw data home for actual position calculation, offloading the hard work, making the mobile unit simpler and cheaper. The newly available spectrum means for him more range and less interference. Exciting times!

11 Nov 11:01 :: 0 comments :: Comment
Tags: technologny, cool, computers, wifi, wireless

Walls and Blocks and Beasts! Oh My!

Some people were poking around for the beast game on #utah today. So I dug up ye olde code and got it to compile without so much as installing some libs and adding a #include. That’s promising, I haven’t touched that code in 4+ years. Anyway it compiles but when you run it the screen is all garbage. #utah says it probably has to do with sfms. I don’t have a hint of time to do anything with it right now, but here I post it anyway in a darcs repo for the whole world to enjoy.

Some history on the project, you can stop reading now if you hate history. This was the first major thing I ever worked on. Before this it was writing a few graphics routines in BASIC for my friends game “Target”. It was then I drew the best ever 8×8 pixel rendition of an angry green blob. Wish I still had that… Prodding the time machine along… My brother Jacob and I set out to clone our good friend beast around 1997-8 in C++. He did all the work at first, with me watching intently and asking such questions as “what does that do?” and “why do it like that?”. Before the end I was writing as much code as he (or at least so I remember it). We had a good ol’ time playing it. When I returned from my mission in 2003 I did a rewrite to port it to linux using ncurses. At some point I also added some fancy self-preservation AI to the beasts. I’m really not sure if the AI stuff is in this version of the code I dug up; I hope it is.

05 Oct 19:42 :: 1 comment :: Comment
Tags: programming, darcs, linux, C++, cool, beast

iDissent

I never could get myself excited about the iPhone, and I began to wonder if I was becoming less of a techie. I would look at the sites, and sure enough it was darn cool. I would read about the interface, the multitouch, the accelerometers. It was all very cool, but did I want one? The answer was consistently no. Sure, if you dropped one in my lap with paid-for service, heck, I’ll take that, and be quite glad. I’ve come to realize that the reasons for my dissent were generally Apple (I guess my anti-apple blood runs thicker than I thought) and more specifically openness, or lack thereof.

I came to this realization after stumbling, nay, tripping over this, and on Yahoo! of all places. The Neo 1973 got me excited like the iPhone couldn’t dream of. I actually want to go out and spend $300 on a phone now (as I’m sure many Apple fans actually want to go out and spend whatever it is for an iPhone), even though it’s a little behind (no multitouch). Still, it has GPS, accelerometers, standard usb hookup (don’t think the iPhone has this), and the whole thing is made to be hackable. It runs on a Linux kernel with X! Oh the joy.

I predict this and other such products will dominate the mobile market the same way intel and it’s many clones did the not-so-mobile market. It will be interesting to see how prices will plummet, cool apps will be in abundance, and there will be a whole slew of Free phones. That reminds me, I love the slogan, “Free your phone.”

So if you want to get me a present (Christmas and my birthday are both coming up) now you know what I want.

25 Jul 20:24 :: 1 comment :: Comment
Tags: linux, open source, cool

XXkb: Per window layout switcher

I came accross this program, xxkb, that will switch keyboard layouts per-window. “Very cool,” I thought, and I proceeded to install it. Once installed I could run it and it would show a tiny English flag in the corner of each window, but beyond that I couldn’t get it to do anything.

Reading the docs in /usr/share/doc/xxkb/ (the man page just points you there) revealed that xxdbdid it’s switching according to xkb configuration. This is where I got lost. I searched for a program called xkb and found xkbsel, xkbevd and other such programs and I thought maybe xkbsel was the one I needed. I couldn’t find a way to configure xkbsel in a manner to affect xxkb, and trying to use xkbsel -s us or any other map just resulted in X locking up and the only thing I could use was the power button.

Back to google again. A search for xkb config and a few hits down got me properly oriented. It turns out xkb is not a program but rather an integral part of X. And likewise those other programs like xkbsel where clients to this bit of X configuration. And since I hadn’t configured it properly, xkbsel did nasty things and xxkb gracefully did nothing.

Well, on to configuring it. Xkb allows X to load up to four keyboard layouts into memory for quick switching between them. To choose these put the following into your appropriate Input Device (keyboard) section:


Option “XkbModel” “pc104” # or whatever keybaord model you have
Option “XkbLayout” “us,kh,dvorak” # just a comma seperated list
Option “XkbOptions” “grp:alt_shift_toggle” # for quick keyboard switching

The alt_shift_toggle is the shortcut key combo to switch between the two most recently used. There are other options but alt_shift_toggle is Alt + RightShift. I am using the layouts us, kh (for Khmer a.k.a. Cambodian) and dvorak. These match in the order they’re given to the numbered groups in the XXkb configuration. To configure XXkb look at the configuration in you X app-default directory (/etc/X11/app-defaults/ on debian) and put changed lines in ~/.xxkbrc. I downloaded some miniature flag images and turned them to xpm for my languages as xxkb only comes with a few european flags.

21 Apr 09:58 :: 0 comments :: Comment
Tags: linux, language, cool, window manager, metacity