Friday, February 10, 2006

Put colours in your Ubuntu startup and shutdown console

One thing I noticed when I first started Ubuntu Hoary was the lack of colors during start up and shut down process.
Then it came Breezy and USplash replaced the anonymous start up console. But the shut down was still in simple black&white text mode. I don't like it, 'cause often I don't see possible errors.
Ok...this is not a big problem, but all other distros have colours, so why Ubuntu doesn't? :-)
I found a simple solution, exploring the file /lib/lsb/init-functions. In this script file you can find functions used by the system for starting and stopping services and, of course, all logging methods.
I modified it to make the console look more colourful. To install it simply do this:

cd ~
wget http://madchicken.altervista.org/tech/download/init-functions.tar
tar xvf init-functions.tar
sudo mv /lib/lsb/init-functions /lib/lsb/init-functions.old
sudo mv init-functions /lib/lsb/init-functions
rm init-functions.tar

And the game is done.
If you want to customize your shell more and more, the way is quite simple: you have only to change echo commands giving the right pattern of characters and colours. To make all things in the right way I used tput command to extract info about the terminal that is running.
Here's simple (really simple!!) guide to tput

tput bold #makes the font bold
tput sgr0 #turns off bold
tput setaf 0-9 #changes the font colour
tput op #reset font colour

You can try all these commands from a standard gnome/kde terminal and see what happens.
A simple example could be:
BOLD=`$TPUT bold`
OFFBOLD=`$TPUT sgr0`
GREEN=`$TPUT setaf 2`
BLUE=`$TPUT setaf 4`
RED=`$TPUT setaf 1`
NORMAL=`$TPUT op`
echo "${BLUE}${BOLD}[ ${GREEN}ok${BLUE} ]${NORMAL}${OFFBOLD}"

This will print the string [ ok ]
And now that you are on the road...happy customization!

3 Comments:

Anonymous digolo said...

te l'ho detto io!!!!!

March 08, 2006 11:17 AM  
Anonymous Anonymous said...

This make my Ubuntu 7.10 "can't initialize hal"...

December 26, 2007 10:51 PM  
Blogger Madchicken said...

Sorry, this is an old script...maybe I'll update for Ubuntu 7.10

January 23, 2008 4:09 PM  

Post a Comment

Links to this post:

Create a Link

<< Home