2009-09-15

IP address on GDM login page

I have several virtual machines that I keep around for various reasons. To save room I usually 7zip them and burn them to DVD. Then I can keep on my drive just the virtual machines that I am currently using.

Often times when I restore a virtual machine and start it running. I will need to access it from another machine on the network, or in the case of a web server, make a firewall rule that will let me be able to access the service from the Internet. Either way, it is a waste of time to have to log into the virtual machine, bring up a shell and run ifconfig to determine the ip address.

This little trick will make it so the ip address of the computer will show up on the GDM login screen. In a nutshell we will edit the GDM startup script to draw the ip address on the background for the current GDM login theme.


I am a big command line guy. So all of the work we will be doing will be done with a shell. So open up Konsole or Gnome Terminal or whatever shell you typically use.

Step 1: Install imagemagick

sudo apt-get install imagemagick


Step 2: Determine the current GDM theme.

cat /etc/gdm/gdm.conf | grep GraphicalTheme=


Will print the current theme. Make note of what it is. In my case it the output of the above command yields:

GraphicalTheme=Human


So I will be working with the Human theme.

Step 3: Determine the background file name.

cat /usr/share/gdm/themes/Human/Human.xml | grep background


Note that I used the theme name exactly as shown noting both uppercase and lowercase letters. The folder the theme files are in matches the theme name and the configuration file matches the theme name and ends in .xml. The output of the above command yields:




So we can see that the name of the background file is background.png.

Step 4: Rename the original background file so we can use it as a "template" to write on when we generate the background file with the ip address written on it.

sudo cp /usr/share/gdm/themes/Human/background.png \

/usr/share/gdm/themes/Human/background-original.png


Step 5: Edit the GDM startup script to take the original background and write the ip address on it and save it out with the name GDM expects to find for the background. Use whatever editor is on your system to do this. For Gnome it will be gedit. For KDE it will be kate for Xubuntu it will be leafpad.

sudo gedit /etc/GDM/Init/Default

Step 6: Change the section that says:

sysmodmap=/etc/X11/Xmodmap
XMODMAP=`gdmwhich xmodmap`

To read:

sysmodmap=/etc/X11/Xmodmap

cd /usr/share/gdm/themes/Human
convert -pointsize 40 -draw \
"fill yellow text 10,50 \" \
`ifconfig eth0 | awk '/inet addr/{print $2 }'`\"" \
background-original.png background.png

XMODMAP=`gdmwhich xmodmap`


Please note the theme name, what network interface you are using (eth0, eth1, etc) and both the name of the original background file and the background file you writing to.

Step 7: Reboot

After rebooting, in large yellow text you will see the ip address of the computer written on the background of the GDM login screen.