Creating Wallpaper Package (deb)

Disclaimer :

I am writing this post because what I found on the internet is pretty outdated or simply doesn’t work. It may be only me who couldn’t find new updated articles for this, but anyway I am going to write this post. Maybe because I haven’t written anything in months.

How to create an install-able wallpaper package for Ubuntu

Motivation

If you are a Ubuntu user, you may have noticed that changing the desktop background also changes the background of the login screen. I like this. However you may have also noticed that the login screen reflects your choice only when you choose one of the default wallpapers, if you choose some other wallpaper then you won’t see the wallpaper in the login screen, even when it is set as your desktop background. I wanted the wallpaper of my choice to be used as the desktop background as well as my login screen.

So I started searching on the internet how to do it, and when i couldn’t find much I found this conversation on Ubuntu Forums. If you follow the conversation you will get an idea of what is to be expected, and how to create a deb package. I tried following the instructions there and when it gave me a few errors I had to improvise and find some things on my own. I had to look into the Ubuntu package guidelines and stuff. I won’t pretend as if I understood all of it, but I understood enough that I got my job done.

I am not going to analyze that discussion on Ubuntu Forum and tell you what’s wrong there. That discussion is pretty old so I guess a lot have changed since then, I will give a updated instruction set on how to make a wallpaper package for Ubuntu.

Get your wallpapers ready

Create / download some wallpapers which you are going to use in your wallpaper package.

Create the skeleton

In order to create a debian package (.deb file), a basic structure of folders is to be followed. I am going to take the example of the wallpaper package I made, and thus I am going to use it’s folder name, but you can use any name.

The folder for my package is named Abstract-Wallpapers, yours can be anything. Inside it there needs to be a folder named DEBIAN (ALL CAPS). Inside it there needs to be at least two files : control and postinst. control file is the file which contains information about the package itself; postinst is a file which contains shell script which will be executed after the installation of the package.

Any other folder created will be copied as they are in the root folder of the operating system. For this wallpaper package we need our image and animation files to be inside /usr/share/backgrounds . This folder will contain our image files and our xml files for transition animation And we need to declare what files do we have for the background and transitions in a separate xml file which resides in /usr/share/gnome-background-properties . The file names can be anything which we will see in a bit, but it’s always easier to avoid using blank spaces in the name of the files, as it makes our lives easier. Not as if it is not possible, it just makes our lives easier.

I am going to explain about these files in a bit, but for now look at the folder structure

Folder Structure

Like I said the files can be named according to your choice, here I have named my jpeg files as Abstract1.jpg Abstract2.jpg …… My animation file as abstract.xml and the file describing my background files as abstract-wallpapers.xml

abstract-wallpapers.xml

This file defines which image files are available as wallpapers and where are those images.

The file needs to have the DOCTYPE declared like this

<!DOCTYPE wallpapers SYSTEM “gnome-wp-list.dtd”>

And then we have to declare the array of wallpapers, it looks like this

<wallpapers>
<wallpaper>
<name>Abstract 1</name>
<filename>/usr/share/backgrounds/Abstract1.jpg</filename>
<options>zoom</options>
<pcolor>#000000</pcolor>
<scolor>#000000</scolor>
<shade_type>solid</shade_type>
</wallpaper>
<wallpaper>
<name>Abstract 2</name>
………………

………………
</wallpaper>

……………………

</wallpapers>

Please keep in mind the blank spaces. They are important. The line <options>zoom</options> tells to zoom and fill in the image. There are other options like crop, spanned etc. Leave the rest of the options as they are. Add in as many wallpapers as you like.

Every wallpaper pack have a slideshow, ours should also have one. So let’s declare the slideshow here. We will define it in a bit inside the backgrounds folder. Adding a slideshow is just like adding a wallpaper. For slideshow we have an xml file, unlike normal wallpapers which have image files.

This is the declaration of slideshow (which goes in the wallpapers array)

<wallpaper deleted=”false”>
<name>Abstract wallpapers by Ishan</name>
<filename>/usr/share/backgrounds/Abstract.xml</filename>
<options>zoom</options>
</wallpaper>

The Slideshow

The slideshow is declared in the backgrounds folder as an xml file with any name. In our case it was Abstract.xml

Te structure of this file is like this :

<background>
<starttime>
<year>2014</year>
<month>09</month>
<day>28</day>
<hour>00</hour>
<minute>00</minute>
<second>00</second>
</starttime>
<static>
<duration>1795.0</duration>
<file>/usr/share/backgrounds/Abstract1.jpg</file>
</static>
<transition>
<duration>5.0</duration>
<from>/usr/share/backgrounds/Abstract1.jpg</from>
<to>/usr/share/backgrounds/Abstract2.jpg</to>
</transition>
<static>
……………….
</static>
<transition>
…………………..
</transition>

……………………..

</background>

The <starttime></starttime> contains the time at which the slideshow will start. Just choose a date and time when you are creating it, thus whenever the user selects the slideshow it works, instead of waiting for a future time to start.

The <static></static> section defines the duration and the location of an image which will be live for that period of time as a static image. The keys inside the static are :

duration : The time for which this image will be shown

file : The image which will be shown

The <transition></transition> is used to define the transition between two images. It has three keys inside it.

duration : The time in which the transition will happen

from : The image from which the transition will happen

to : The image to which the transition will happen

These are fairly obvious options, which don’t need any explanation.

 

Now comes the part of making the package

We need to define the options for the package. This is done in the control file.

Here is the file and it’s explanation :

File :

Package: abstract-wallpapers-ishan
Version: 0.0.1
Architecture: all
Maintainer: Ishan <ishanatmuzaffarpur@gmail.com>
Installed-Size: 3170
Section: x11
Priority: optional
Description: Abstract wallpapers handpicked by Ishan

 

Explanation :

Package : The name of your package

Version : The version of your package. It must start with a number. I recommend using Semantic Versioning

Architecture : The architecture with which your package is compatible. In our case it’s just a wallpaper pack so we can set it to all, as it runs on all architectures. But in general if your packaging a software that you made set the architecture carefully (i386, amd64 …..).

Maintainer : This contains the name and email in this format name <email>

Installed-Size : This is the size of the hard disk space the package is going to take after installation (i.e. after all the setup is complete). The unit is in KBs. This needs not be exact, but an approximate. I just checked the size of the folder and used it. But if you are making a package for another app, please make sure that you enter the size of the space it takes after installing the software, not just the size of the source.

Section : This is the section (cateogry) in which your package should appear. This is the section in which your package appears. There are many sections like :

admin – administrator-only programs

devel – programmer tools

doc – documentation

libs – libraries

mail – email readers and daemons

net – network apps and deamons

X11 – X11 programs that don’t fit anywhere else

There are more; The whole list can be found here

Since the X11 makes sense in our case, I used that.

Priority : This describes how important is the installation of your package. The possible options are: required, important, standard, extra and optional. In our case the installation of package is totally optional.

Description : This is the description of your package.

 

One more file that is remaining is the postinst file under the DEBIAN folder. This file is a shell script, which gets executed after the installation of your package. In our case it means that this will get executed after the copying of the files in their desired location.

This is a wallpaper pack, we aren’t doing much. We just need to make the wallpapers readable by the users. chmod command does that very well. Here is the script.

#!/bin/bash

chmod a+r /usr/share/backgrounds/*

exit 0

In the sample that I was using they set the chmod command for each file, but I thought what the hell, when I can do it in one line, why use 20?

 

At this stage all the preparation of the files are done. It’s time now to make the package.

There are few steps to packing :

1. Make the postinst file executable and readable. Set it’s permission to 755.

2. Set the root as owner of the folder (This is important).

3. Package the folder.

And here are the codes to do the same:

1. Making postinst executable :

cd Abstract-Wallpapers/DEBIAN/

sudo chmod 755 postinst

2. Set the root as owner :

sudo chown root.root -R Abstract-Wallpapers

3. Package the folder :

dpkg -b Abstract-Wallpapers Abstract-Wallpapers.deb

 

Once all these steps have been successfully executed. All you need to do is share the deb file with your users and tell them to install it, either by opening and installing via Software Center or via terminal.

 

Note : All the code and files can be found on my github repo Abstract-Wallpapers-Pack

Please put in your words.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s