Prettifying Debian boot output

Jan 7, 2010 / 0 comments

Being a bit of a freak I actually tend to read my boot output. Well, when I'm not using that time to go grab a cup of coffee first thing on a Monday morning. However I don't always find Debian's default output as clear as I'd like (especially when I haven't had that coffee yet, or when I'm half watching a remote machine boot over its serial console). ISTR that RedHat had much nicer boot output (I'm talking about text based here, not the fancy Plymouth stuff) with a row of OK/FAILED etc down the right hand side that made it nice and obvious what was happening. Of course we can do that with Debian, at least for packages that use the lsb-base logging functions. Drop the following into /etc/lsb-base-logging.sh and enjoy a slightly prettier boot. I'm slowly filing wishlist bugs with patches for those bits and pieces I use that don't use lsb-base for their init script logging.

# Colour our init scripts output

# int log_end_message (int exitstatus)
log_end_msg () {
    # If no arguments were passed, return
    if [ -z "${1:-}" ]; then
        return 1
    fi

    retval=$1

    log_end_msg_pre "$@"

    # Only do the fancy stuff if we have an appropriate terminal
    # and if /usr is already mounted
    if log_use_fancy_output; then
        RED=`$TPUT setaf 1`
        GREEN=`$TPUT setaf 2`
        YELLOW=`$TPUT setaf 3`
        NORMAL=`$TPUT sgr0`
        $TPUT hpa $((`$TPUT cols` - 12))
    else
        RED=''
        GREEN=''
        YELLOW=''
        NORMAL=''
    fi

    if [ $1 -eq 0 ]; then
        /bin/echo -e " [   ${GREEN}OK${NORMAL}   ]"
    elif [ $1 -eq 255 ]; then
        /bin/echo -e " [${YELLOW}WARNING!${NORMAL}]"
    else
        /bin/echo -e " [ ${RED}FAILED${NORMAL} ]"
    fi
    log_end_msg_post "$@"
    return $retval
}

log_action_end_msg () {
    log_action_end_msg_pre "$@"
    if [ -z "${2:-}" ]; then
        end=""
    else
        end=" ($2)"
    fi

    /bin/echo -n "${end}"

    # Only do the fancy stuff if we have an appropriate terminal
    # and if /usr is already mounted
    if log_use_fancy_output; then
        RED=`$TPUT setaf 1`
        BLUE=`$TPUT setaf 4`
        NORMAL=`$TPUT sgr0`
        $TPUT hpa $((`$TPUT cols` - 12))
    else
        RED=''
        BLUE=''
        NORMAL=''
    fi


    if [ $1 -eq 0 ]; then
        /bin/echo -e " [  ${BLUE}DONE${NORMAL}  ]"
    else
        /bin/echo -e " [ ${RED}FAILED${NORMAL} ]"
    fi
    log_action_end_msg_post "$@"
}

(This is mostly for my own future reference, because I keep trying to search for details on it and not finding exactly what I want. I forget where I even found the basis for this, though there are lots of similar snippets out there. I've not tried it with a concurrency based boot so it may well look horrible under that.)

Neat find of the day: inputlirc

Dec 24, 2009 / 0 comments

I've recently been fixing up my VDR setup to work with FreeSat and make it brother/parent friendly. I've applied the EPG patches to get the 7 day guide, setup an autologging in user under gdm with vdr-sxfe running and that left getting the remote working. For some reason my old serial dongle wasn't happy with lirc - it got detected ok, and would show some signal when buttons were pressed but didn't work with the old config. The entire hardware of the box has changed, so it seems likely something isn't quite right (in particular the lirc drivers spew out warnings about SMP bits so I should probably try the dongle under a single core setup to rule that out, but there's also a move to 64 bit involved).

The easy solution to have something sorted for Christmas was to pickup a cheap remote from eBay. This ended up being a Cyberlink remote + USB dongle combo. Worked just fine when plugged in, turning up as a normal input device and the obvious keys doing the obvious things. I wanted all the keys to work though, as I'd got used to having a lot of the VDR functions instantly accessible rather than having to work my way through the menus. Various searches suggested I'd need to use LIRC to access the odder keys. That seemed a lot of hassle for something that was doing the decoding itself. Some playing with xev turned up keycodes for a number of the keys, but there were still a few missing (and important ones at that, such as Red/Green/Yellow/Blue). Further digging found me a suggestion of an Xorg keyboard map that would map the KEY_RED etc from the evdev device into something workable under X. And then I found inputlirc via the Debian package. This is really bloody neat - point it at an evdev device and it will present all of the KEY_* codes out as lirc keys. If you pass the -g parameter it makes sure the key presses only go to lirc as well. Exactly what I want and a doddle to setup - no messing with a big configuration file, just edit /etc/defaults/inputlirc to point to the correct /dev/input/by-id/ file, add the -g to the options in that file and restart.

Now the main remaining task is to get it working with BBC/ITV HD.

DIY laptop SSD "upgrade"

Nov 29, 2009 / 0 comments

I'm due a new laptop; my Portege R200 is over 4 years old now, I find it much slower than my desktop (no surprise; P-M 1.2GHz/1.2GB vs Core 2 2GHz/4GB), it's had a new battery and it has an annoying whine on the screen unless you press the side in just the right way. It's still better for long periods of use than my EEE 901, which is why I keep it. In particular I'm off to LCA2010 in January, along with some associated travel beforehand, and I'll want more than the EEE for that, but probably not a brand new laptop. Which meant that when the R200 started throwing disk errors recently I wasn't particularly happy.

Having decided it wasn't worth buying a new 1.8" drive I looked for alternatives. eBay offered plenty of options for 1.8" IDE to CF adaptors and I picked up a Kingston 32GB CF card from eBuyer. I copied across the data from the old drive using a USB adaptor, frobbed grub sufficiently that I got it installed on the CF, then swapped out the drive for the adaptor + CF. I had to do the swap a few times; the first I forgot to have a kernel with ext2 support (the HDD was ext3, but I went back to ext2 for the CF). The second I'd done my usual trick of forgetting to populate /dev with things like console and sda* (ie enough to get to the point where udev will run). And then grub needed some prodding to boot without intervention. I got there in the end and I'm currently writing this from said laptop.

I've made a few changes to the Debian install in an attempt to make things smoother; basically the same tricks people have been using on EEEs or other slow SSD devices. No swap, Iceweasel synchronous toolkit writes disabled, filesystems mounted with noatime, /tmp on tmpfs, various daemons that I don't really use disabled. It's still noticably slower than with the HDD, particularly on writes. However it's quieter and as long as it lasts for the next 3 months I'm happy (plus after that I can reuse the 32G CF card somewhere else, which I couldn't have done with a 1.8" HDD as easily).

Now, back to eyeing the Lenovo X200s (ugly, trackpoint but 1440x900 display, good battery life) and Toshiba R600 (slower, lower res but pretty and trackpad).as potential replacements. Maybe there'll be something even shinier in 12" by next year...

Playing with an e-reader

Nov 15, 2009 / 0 comments

I've always preferred dead tree to reading things on screen; I just find it easier. I've tried reading fiction in the past off a laptop and just didn't find it as enjoyable an experience; whether it was the form factor (hard to curl up with a laptop, even a netbook), the quality of the screen or the interface I don't know. Equally with technical documentation if it's something I'm using a lot I prefer a printed copy to flick through. However e-ink based e-readers are becoming much more common and affordable and I figured I should give the whole ebook experience another try.

I spent 3 weeks in October in the Bay Area on work, so I borrowed my Dad's Sony PR505 for the trip. First problem is that it's picky about USB charging - works fine if attached to a computer, but using a Blackberry charger looks like it's fine but then results in what looks like a hanging reader. However once charged it lasts for ages - I charged it before I went and only hooked it up to my laptop once during the trip to transfer some new content onto it. The form factor is also quite good; a bit heavier than a book, but not excessively so. Holdable in one hand, big enough screen that I wasn't squinting at it. Slightly too big physically to easily go in a coat pocket the way a paperback would unfortunately, but perfectly fine for taking to read at breakfast every morning in the hotel.

The screen was also much better than I'd expected. I knew the technology was different and supposed to be easier to read than traditional LCDs, but I was sceptical. Overall I had no problems with it. I was even quite impressed with the Sony's zoom function - one of the PDFs I was reading was too small when view full screen, so I zoomed in so it was readable. The nice feature was that then the "next page" button gave me the next bit of text to read, rather than the actual next page, so it remained very easy to navigate through as I read. A small touch, but very welcome.

This isn't intended to be a review of the Sony reader; that just happened to be the model I was easily able to borrow. I happened to see a Kindle in use on the plane and I was struck by how much bulkier it seemed, though having looked at the relative specs it seems this is entirely due to the keyboard rather than any difference in screen size. The Nook was also announced during my trip and I'd quite like a play with that as it looks quite nice.

Despite my positive experience with the Sony I'm not planning to go out and get one just yet. And that's the lack of sensibly priced content. When I bought my first mp3 player I could take my exising CD collection, rip it and be able to play it on my new device. This meant I got an immediate benefit of having my entire music collection with me all the time, just by buying the player. If I buy an e-reader then in order to get all my existing books on it I have to go and buy them again. What's worse is they'll cost me the same or more than I paid for the paperbacks. I can't go and exchange my Pratchett collection for the electronic versions for a nominal fee. I can't easily scan them in myself and produce some decent ebooks. I can't even go and buy the entire set for £20; I'd have to spend something like ten times that. With mp3s I can continue to buy the real item and also have it on my portable player. Or, while albums still don't seem to be much cheaper electronically than on CD, there is at least the ability to buy a single track if that's all I want. Books don't have a comparison. I'm not going to want to buy a single chapter, am I?

There are some sites out there that can provide cheaper ebooks - Rachel Willmer runs ebookprice.info which lets you compare pricing from different vendors. There's also Project Gutenberg if you're looking for out of copyright books. Finally Peter Corlett pointed me at the Baen Free Library, which I haven't downloaded anything from but will definitely investigate at some point. I still maintain that none of these are enough and that content provision will continue to be a hinderance for e-reader mass adoption until there is some fundemental change in the way its provision is handled.

What to wear?

Oct 13, 2009 / 0 comments

I tend to dress quite casually - unless there's a good reason to do otherwise I'll be in jeans and a t-shirt, or something similar. I'm comfortable in it and I take the view point that in general people shouldn't be making assumptions based on what I'm wearing. Of course they do, and while this can be infuriating at times it can also be amusing. The man at the RBoS who witnessed me signing the personal DD guarantee form for Black Cat obviously couldn't reconcile my appearance with what I was there to do, for example.

I'd never thought about this from the other side until a few weeks ago. I spoke to someone who explained how difficult it had become to conduct business meetings with other companies with the increased level of business casual. In fact on occasion different branches of the same company that he'd be meeting with would have different dress codes, so he'd go to something involving casual dress in the morning and something with full business suit attire in the afternoon and end up feeling over or under dressed.

This isn't likely to make me change my own behaviour in the immediate future (I don't have to interact with external parties as part of my current job). It did help me realise that there was another explanation for awkward behaviour when I'm my usual scruffy self that wasn't just about judging on appearances though.

(All of the above blatantly obvious once you think about it, but it took that conversation for me to do so.)

subscribe via RSS