Saturday, January 12, 2013

How to Take Screenshots of the Login Screen in Ubuntu 12.10

Last month when I posted about installing multiple desktops environments within Ubuntu, I found myself needing to take a screenshot of the login screen. It wasn't immediately obvious how this could be done but after a bit of fiddling around I managed to find a good solution that I thought I would share. First off, you will need to make sure imagemagick is installed. Open the terminal and type:

sudo apt-get install imagemagick

After it installs we are going to create a script to take the screenshot for us. I like to keep my scripts in a folder called “Scripts” within my home directory but you can create it anywhere you like. In the terminal type:

sudo nano screenshot.sh

This will open nano, a simple terminal based text editor. On the first line type:

This script will exit the console mode, wait for five seconds (you can change this to anything you like), capture the screen into a file called temp.xwd and finally convert it to a png. Now type ctrl-x to save the script. In order to run it however, we will need to make it executable, so type:

sudo chmod +x screenshot.sh

Now log out of your session and once you are back to the login screen type ctrl-alt-1 to open the console mode. You will have to login with your username and password, and then navigate to the folder where the script is located and type:

sudo ./screenshot.sh

Enter your password and the script will boot you back into lightdm and after five seconds it will capture the screen. To see the image log back in to ubuntu and navigate to your home folder. There you should find a new file called screenshot.png