📦 Waddle Run, Episode 11

From a folder of files to a program with a menu entry, an icon and a package. Three small steps.

Video: Waddle Run, Episode 11 (Waddle Run video)
Prefer to watch? This short video runs this page's main commands on a real Ubuntu 24.04 desktop, with on-screen captions and a synthetic voiceover (an AI voice trained on the author's own recording). Click to play, or watch it on YouTube.
Episode 11 is the last one. It ends with this: Waddle Run in the GNOME menu with its own icon, the right icon in the dock while it runs, a manual page (man waddle-run), a command that works from any folder, and a single .deb file that anyone on Ubuntu can install and remove with apt.

You will need: your project from episode 10 (a game.py and the art, sounds and music folders), or the starter files below, and a clean Ubuntu 24.04 to try the package on.
You will make: six small files in a packaging folder, and a .deb package. game.py needs no change: episode 10 already gave the window its class name.
You will learn: what GNOME needs to show a program in the menu and the dock, how a Debian package is laid out, dpkg-deb, and lintian.
Starter files: waddle-run-ep10.zip is where this episode begins, waddle-run-ep11.zip is where it ends. The last one has the packaging folder in it.

The package was built, checked with lintian and desktop-file-validate, installed with apt on a clean Ubuntu 24.04 (first in a container, then on a GNOME desktop on Xorg), started from the menu and from a terminal, and removed again. The commands and the output on this page are from those runs.

Where we start

Open a terminal, go to the project, turn on the virtual environment and run the game:

$ cd waddle-run
$ source .venv/bin/activate
(.venv) $ python game.py

The game is complete: a title screen, music, sound effects, a best time. But it only starts from a terminal, from its own folder, and while it runs the dock shows a plain gear with no name: the desktop does not know what this window is.

What the dock needs, and where it is already done

For the desktop to recognise a window as Waddle Run it needs one name in two places: the window's class name (set by the game) and StartupWMClass in a desktop file (set by the package). The game's side was added in episode 10, in the first lines of game.py:

os.environ.setdefault("SDL_VIDEO_X11_WMCLASS", "waddle-run")
import pygame

SDL_VIDEO_X11_WMCLASS       pygame uses a library called SDL for its window. On X11 (and on Xorg under GNOME) every window has a class name, and the desktop uses it to decide which program the window belongs to, so which icon to show and which dock entry to group it with. SDL reads the name from this environment variable
setdefault                  sets the variable only if nobody set it already, so you can still override it
above import pygame         SDL reads the variable when pygame is first loaded. Set it afterwards and nothing happens

Nothing in game.py changes in this episode. All the work is six files in a folder next to it.

Step 1: the launcher, the desktop file and the control file

Make a folder packaging/ in the project and put these files in it. First the launcher, packaging/waddle-run: a script that starts the game from wherever it is installed.

#!/bin/sh
exec python3 /usr/share/waddle-run/game.py "$@"

exec                               replaces the shell with Python, so there is no extra process left
/usr/share/waddle-run/game.py      where the package will put the game
"$@"                               passes on any arguments you give the command

The desktop file, packaging/waddle-run.desktop, is what puts the game in the menu:

[Desktop Entry]
Type=Application
Name=Waddle Run
Comment=Run, jump and stomp through an icy world as Tux the penguin
Exec=waddle-run
Icon=waddle-run
Terminal=false
Categories=Game;ArcadeGame;
StartupWMClass=waddle-run

Name, Comment                      what the menu shows
Exec=waddle-run                    the command to run (the launcher, found on the path in /usr/games)
Icon=waddle-run                    the name of an icon, without the extension. The desktop looks for waddle-run.png in its icon folders
Terminal=false                     it is a window, so no terminal around it
Categories=Game;ArcadeGame;        where it appears in a menu
StartupWMClass=waddle-run          the class name from the game. This line is what lets the dock match the window to this entry

The control file, packaging/control, is the package's identity card:

Package: waddle-run
Version: 1.0.0
Section: games
Priority: optional
Architecture: all
Depends: python3, python3-pygame
Maintainer: TechCommune <admin@techcommune.org>
Description: Side-scrolling platformer: Tux the penguin versus grumpy crabs
 Run, jump and belly-slide through an icy level, collect fish, stomp on
 crabs and snowballs, dodge icicles and spikes and reach the igloo.
 Built with pygame as a tutorial series for techcommune.org.

Package, Version, Section          the name, the version and where it is filed (games)
Architecture: all                  it is Python, so one package works on every kind of computer
Depends: python3, python3-pygame   what apt installs with it. This is the line that makes the package install pygame for the user
Maintainer                         who to ask. Change it to yours
Description                        a short line, then more lines that start with one space

Four more files complete the package. They are plain text or a picture, and they are all in the starter zip:

packaging/changelog                the history of the package. Debian wants one, even for a first release
packaging/copyright                who owns it and what you may do with it. This one says: free to use in your own projects, credit appreciated. Put in what is true for your own game
packaging/waddle-run.6             the manual page, in the old roff format. The 6 is the section for games
packaging/waddle-run.png           the icon, 128 by 128 pixels: Tux on a snow hill under a starry sky, on a rounded square, drawn with make_icon.py (in the zip)
packaging/build_deb.sh             the script that builds the package, in the next step

Step 2: build the package

A .deb file is an archive that holds the files laid out as they will be on the user's machine, plus the control file. The build script makes that layout in a folder, and packs it with dpkg-deb:

#!/bin/sh
# Build waddle-run_1.0.0_all.deb from this game folder. Run it from anywhere: sh packaging/build_deb.sh
set -e
cd "$(dirname "$0")/.."
V=1.0.0
P=build/waddle-run_${V}_all
rm -rf build
mkdir -p $P/DEBIAN $P/usr/games $P/usr/share/applications $P/usr/share/doc/waddle-run \
  $P/usr/share/icons/hicolor/128x128/apps $P/usr/share/waddle-run $P/usr/share/man/man6
cp game.py $P/usr/share/waddle-run/
cp -r art sounds music $P/usr/share/waddle-run/
install -m 755 packaging/waddle-run $P/usr/games/waddle-run
install -m 644 packaging/waddle-run.desktop $P/usr/share/applications/
install -m 644 packaging/waddle-run.png $P/usr/share/icons/hicolor/128x128/apps/waddle-run.png
install -m 644 packaging/copyright $P/usr/share/doc/waddle-run/copyright
gzip -9n -c packaging/changelog > $P/usr/share/doc/waddle-run/changelog.gz
gzip -9n -c packaging/waddle-run.6 > $P/usr/share/man/man6/waddle-run.6.gz
install -m 644 packaging/control $P/DEBIAN/control
find $P -type d -exec chmod 755 {} +
find $P/usr/share -type f -exec chmod 644 {} +
dpkg-deb --root-owner-group --build $P
mv build/waddle-run_${V}_all.deb .
echo "built waddle-run_${V}_all.deb"

What it does:

P=build/waddle-run_${V}_all        the folder where the layout is made, and the name of the package file
usr/games, usr/share/...           the places on a Linux system for games, shared files, documentation, icons, manual pages and desktop files. A package puts files where each kind belongs
cp -r art sounds music             the whole game goes under /usr/share/waddle-run, next to game.py. The game finds its art, sounds and music in its own folder, so it does not care where it is installed
the best time                      is not in the package. The game writes it to ~/.local/share/waddle-run in your own home, so an installed game, which nobody can write to, still works
changelog.gz, waddle-run.6.gz      documentation is stored compressed. gzip -9n gives smaller files and no timestamp inside them
find ... chmod                     directories get 755 and files 644, so the permissions do not depend on your umask
dpkg-deb --root-owner-group        packs the folder. The flag makes everything in the package owned by root, whoever built it

Run it, and look at the result:

$ sh packaging/build_deb.sh
dpkg-deb: building package 'waddle-run' in 'build/waddle-run_1.0.0_all.deb'.
built waddle-run_1.0.0_all.deb
$ dpkg-deb -I waddle-run_1.0.0_all.deb
 new Debian package, version 2.0.
 size 1625974 bytes: control archive=409 bytes.
     445 bytes,    11 lines      control
 Package: waddle-run
 Version: 1.0.0
 Section: games
 Priority: optional
 Architecture: all
 Depends: python3, python3-pygame
 Maintainer: TechCommune <admin@techcommune.org>
 Description: Side-scrolling platformer: Tux the penguin versus grumpy crabs
  Run, jump and belly-slide through an icy level, collect fish, stomp on
  crabs and snowballs, dodge icicles and spikes and reach the igloo.
$ dpkg-deb -c waddle-run_1.0.0_all.deb | grep -v -e art/ -e sounds/ -e music/
(the package also holds the pictures, sounds and music, which are left out here:)
drwxr-xr-x root/root         0 2026-11-18 15:04 ./
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/games/
-rwxr-xr-x root/root        58 2026-11-18 15:04 ./usr/games/waddle-run
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/applications/
-rw-r--r-- root/root       218 2026-11-18 15:04 ./usr/share/applications/waddle-run.desktop
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/doc/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/doc/waddle-run/
-rw-r--r-- root/root       139 2026-11-18 15:04 ./usr/share/doc/waddle-run/changelog.gz
-rw-r--r-- root/root       114 2026-11-18 15:04 ./usr/share/doc/waddle-run/copyright
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/icons/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/icons/hicolor/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/icons/hicolor/128x128/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/icons/hicolor/128x128/apps/
-rw-r--r-- root/root     17465 2026-11-18 15:04 ./usr/share/icons/hicolor/128x128/apps/waddle-run.pn
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/man/
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/man/man6/
-rw-r--r-- root/root       574 2026-11-18 15:04 ./usr/share/man/man6/waddle-run.6.gz
drwxr-xr-x root/root         0 2026-11-18 15:04 ./usr/share/waddle-run/
-rw-r--r-- root/root     25916 2026-11-18 15:04 ./usr/share/waddle-run/game.py


(Your times will differ.) The last check is lintian, a program that knows the rules of Debian packaging. It is a separate package (sudo apt install lintian):

$ lintian --pedantic waddle-run_1.0.0_all.deb
$ echo $?
0

No output means no complaints, even with --pedantic, which looks at the small things too. (Checked in an Ubuntu 24.04 container; lintian printed only its own note that running as root is not recommended.) The desktop file passes desktop-file-validate with no output, too.

Step 3: install it and start it like any other program

Install the file with apt. The ./ in front matters: it tells apt that this is a file and not the name of a package in the archive.

$ sudo apt install ./waddle-run_1.0.0_all.deb

apt reads the control file, sees Depends: python3, python3-pygame, and installs those too (python3-pygame comes with a handful of libraries). If the .deb file is in your home folder, apt may end with a notice that begins 'Download is performed unsandboxed as root as file ... couldn't be accessed by user _apt'. It is harmless: apt's own download user cannot read your home folder, so apt reads the file as root. Then:

1  Press the Super key (the one with the Windows logo), type waddle, and Waddle Run is there, with its icon. Press Enter.
2  The game starts on its title screen. In the dock it has Tux's icon and the little dot of a running program, because the window's class name matches StartupWMClass in the desktop file.
3  Open a terminal and type waddle-run: the same game starts, from any folder, because the launcher is in /usr/games.
4  man waddle-run shows the manual page.

(Checked on a clean Ubuntu 24.04 container: apt installed the package and python3-pygame 2.5.2 from the Ubuntu archive, dpkg -l showed it as installed (ii), /usr/games/waddle-run started the game, and it kept running until a six second timeout stopped it with exit status 124. Then on a GNOME desktop on Xorg: typing waddle in the Activities search found the game with its icon, Enter started it, the dock showed Tux's icon with the running dot, and man waddle-run showed the page, from /usr/share/man/man6/waddle-run.6.gz.)

To remove it again:

$ sudo apt remove waddle-run

(Checked: the files in /usr/share/waddle-run and /usr/games were gone and dpkg no longer listed the package.) Nothing is left behind except your best time in ~/.local/share/waddle-run, which is your own file.
Typing waddle in the GNOME Activities search finds Waddle Run with its icon
Typing "waddle" in the Activities search (a screenshot of the test desktop).
Waddle Run episode 11 running
Running from the menu: Tux's icon and the running dot in the dock (a screenshot of the test desktop).

Where to go from here

You now have a game made in eleven small steps, from an empty window to a package. Some ideas for what to do with it:

a new level                       LEVEL is a list of strings. Draw your own, with more ice, or a long run of icicles
a second hazard                   a moving platform, a bouncy snow cloud, a crab that jumps
a gamepad                         pygame can read joysticks
your own pictures and sounds      draw pictures in any program that saves PNG files, and change the numbers in make_sounds.py and make_music.py (they are in the ep10 and ep11 zips) to hear what they do
a new version of the package      change the version in control and build_deb.sh, add a line to the changelog, and build again

The series is also a template for any small Python program that you want to give to somebody else: a launcher, a desktop file, a control file, and one script that builds it.

Check your work

If something is different:

dpkg-deb: error: control file ... missing        packaging/control is missing or is not in the right folder
lintian: E: no-changelog / W: no-manual-page      the changelog.gz and the manual page are missing from the package
the menu does not show the game                  the desktop file is not in /usr/share/applications, or it has a typo. Run desktop-file-validate on it. A new entry can take a moment to show up: log out and in again if it does not
the menu shows it, but with a gear               the Icon= name and the icon file name must match: waddle-run.png in hicolor/128x128/apps
the dock shows a second, gear icon               StartupWMClass must be the same as the class name in game.py, and the os.environ line must be above import pygame
dependency problems on install                   run: sudo apt install ./waddle-run_1.0.0_all.deb (with the ./) and read what apt says it cannot find
the best time is not saved                       it goes to ~/.local/share/waddle-run/best.json: check that you can write to your home folder

Not run: other Linux distributions, Wayland-only sessions, RPM and other package formats, and uploading the package to a repository. The sound was not heard on the desktop test (the virtual machine has no sound card), only loaded.