Suppose we want to change the functionality of an Ubuntu application but we do not want to go into all the trouble of finding the source code, installing in /usr/local/, breaking dependencies with original versions and so on.
Let’s change Character Map (gucharmap), and specifically change the default font size from 20pt to 14pt, so that when you start it there is more space in the character window. Currently Character Map does not offer an option to save this setting.
We get the source code of Character Map,
# apt-get source gucharmap
and now we edit the file gucharmap/main.c
We know what to edit because we visited the GNOME CVS Website, at http://cvs.gnome.org/viewcvs/gucharmap/
and we examined the logs for the file http://cvs.gnome.org/viewcvs/gucharmap/gucharmap/main.c?view=log
which show that for Revision 1.69, the following change took place,
Log:2004-02-01 Noah Levitt * gucharmap/gucharmap-table.c: Improve square size. * gucharmap/main.c: Increase default font size.
When we click on the link Diff to previous 1.68 of the above page, we pinpoint the change,
|version 1.68, Sun Feb 1 03:46:21 2004 UTC||version 1.69, Mon Feb 2 00:48:05 2004 UTC|
|Line 93 main (gint argc, gchar **argv)|
|Line 93 main (gint argc, gchar **argv)|gint default_size = PANGO_PIXELS (1.5 * pango_font_description_get_size (window->style->font_desc));
gint default_size = PANGO_PIXELS (2.0 * pango_font_description_get_size (window->style->font_desc));
The change in the multiplier (from 1.5 to 2.0) changes the font size from 15pt to 20pt.
20pt is too big for us, therefore we edit the file gucharmap/main.c and change the 2.0 to 1.4 (14pt).
At this point we can compile the package using the command line
$ dpkg-buildpackage -rfakeroot -uc -b
dpkg-buildpackage: source package is gucharmap
dpkg-buildpackage: source version is 1:1.4.4-1ubuntu1
dpkg-buildpackage: source changed by Sebastien Bacher
dpkg-buildpackage: host architecture i386
fakeroot debian/rules clean
At this point it is possible that you will get an error that an essential package is missing. The above command line will name the missing files, therefore you can simply install by
# apt-get install package-name
In case you do not have the basic compiler packages, you would need to install the build-essential meta-package. Do
# apt-get install build-essential
Finally, after the dpkg-buildpackage command completes, it will create one or more .deb packages in the directory above gucharmap.
# cd ..
# ls -l *.deb
You can now install them (over the original packages) by running
# dpkg -i gucharmap_1.4.4-1ubuntu1_i386.deb libgucharmap4_1.4.4-1ubuntu1_i386.deb libgucharmap4-dev_1.4.4-1ubuntu1_i386.deb
Now we start the Character Map from Applications/Accessories/ and we get the default character size of 14pt!
Is there something we should pay attention on top of this? Yes, we should investigate the GNOME Bugzilla in case there is relevant work on this issue. We visit
and specifically we click on the link Browse.
There, we select the package gucharmap (how do we know that Character Map is gucharmap? We either click on Help/About in Character Map which shows the internal name, or we run ps ax at a Applications/Accessories/Terminal while Character Map is running; the name gucharmap will pop up at the end of the long list.).
gucharmap is under the Desktop heading in the Browse list; or click on this direct link of bug reports on gucharmap.
If you start perusing the gucharmap bugs list, you will notice Bug #140414, titled remember settings. This report describes a superset of the problem we tried to solve above. That is, the bug report asks to enable Character Map to use the GNOME configuration database (gconf) so that it saves/remembers the user settings. However, this specific bug report is still pending.
The correct way to solve the configuration settings issue of gucharmap is to implement what is described in Bug #140414. If you have Ubuntu 6.06, you most likely have a very recent version of the source code of gucharmap. Therefore, the differences would be rather minimal. You can give it a go and try to get the gconf functionality in place.
You compile, install and test. If it works, you can make a patch of your changes; visit another directory and download a fresh copy of the source code using the apt-get source packagename command. Rename gucharmap-1.4.4 to gucharmap-1.4.4.ORIGINAL
# mv gucharmap-1.4.4 gucharmap-1.4.4.ORIGINAL
and make sure you clean the original gucharmap-1.4.4/ directory from compiled files (enter the directory were you did the source code changes and run make clean).
Finally, create a diff file,
# diff -ur ~/tmp/gucharmap-1.4.4.ORIGINAL ~/gucharmap-1.4.4/ > remember-settings.patch
In ideal terms, it is preferable if you could produce a patch for the latest version of gucharmap. That is, the version of gucharmap you get from http://cvs.gnome.org/viewcvs/gucharmap/. By doing so, the developers will love you because they will be able to simply apply the patch and limit the burden of adding the feature. Indeed, if it is too much effort to get a build system running, you can start off with simple patches and if you feel you are doing well with it, make the extra mile to have a build system. More on this in a future post.