Skip to content

Instantly share code, notes, and snippets.

@danielrosehill
Created July 23, 2026 18:49
Show Gist options
  • Select an option

  • Save danielrosehill/752e8aed91f822ae1b434c53f38aa1a0 to your computer and use it in GitHub Desktop.

Select an option

Save danielrosehill/752e8aed91f822ae1b434c53f38aa1a0 to your computer and use it in GitHub Desktop.
Getting bambam (the baby keyboard-masher game) running on Linux Wayland — KDE Plasma / GNOME

Getting bambam (the baby keyboard toy) working on Wayland

bambam is a lovely little "keyboard masher" game for babies and toddlers: they bash the keyboard and mouse, and instead of emailing your boss or closing your windows, the screen fills with colourful shapes, letters and sounds. It grabs the keyboard/mouse so the little one can't wreck anything.

Install is a one-liner on Debian/Ubuntu:

sudo apt install bambam

But on a modern Wayland desktop (KDE Plasma, GNOME) it fails in two annoying ways, and the error messages don't make the fix obvious. Here's what's going on and how to make it work — tested on Ubuntu with KDE Plasma on Wayland.

The two problems

  1. It silently self-closes. bambam's graphics run on pygame/SDL2, and SDL2's native Wayland backend bails out immediately — the window flashes and vanishes.

  2. It refuses to run on purpose. Newer bambam versions detect Wayland and quit with:

    Error: Wayland display detected. Cannot lock the keyboard safely. Press any key to quit.

    This is a deliberate safety guard: on Wayland an app generally can't fully grab the keyboard the way it can on X11, so the authors would rather refuse than give you a false sense of a "locked" screen. (See the check in the source — it trips on the WAYLAND_DISPLAY or XDG_SESSION_TYPE=wayland environment variables.)

The fix

Two changes, together:

  1. Route it through XWayland instead of native Wayland — this stops the self-close. Set SDL_VIDEODRIVER=x11. (XWayland is already running on any normal KDE/GNOME Wayland session, so there's nothing to install.)
  2. Pass the --wayland-ok flag — an intentionally undocumented option that skips the refusal guard.

Quick test from a terminal:

SDL_VIDEODRIVER=x11 bambam --wayland-ok

To quit the game, just type the word quit (q-u-i-t) — chosen because a mashing baby is very unlikely to spell it by accident.

Make it permanent (launcher + menu entry)

So you never have to remember any of that, wrap it in a small launcher.

~/.local/bin/babytime (then chmod +x ~/.local/bin/babytime):

#!/usr/bin/env bash
# babytime — launch bambam reliably on a Wayland desktop.
#   1. pygame's native Wayland backend self-closes -> route through XWayland.
#   2. bambam refuses to start under Wayland        -> pass --wayland-ok.
export SDL_VIDEODRIVER=x11
exec bambam --wayland-ok "$@"

~/.local/share/applications/babytime.desktop (gives you a clickable menu icon):

[Desktop Entry]
Type=Application
Name=Baby Time (bambam)
Comment=Baby-safe keyboard masher — type "quit" to exit
Exec=/home/YOURNAME/.local/bin/babytime
Icon=applications-games
Terminal=false
Categories=Game;KidsGame;

Then update-desktop-database ~/.local/share/applications.

Optional: the stock package installs its own "bambam" menu entry that runs the broken command. Hide it with a user override so only your working launcher shows:

cat > ~/.local/share/applications/bambam.desktop <<'EOF'
[Desktop Entry]
Type=Application
Name=bambam
Exec=/usr/games/bambam
NoDisplay=true
Hidden=true
EOF
update-desktop-database ~/.local/share/applications

One caveat: the keyboard lock isn't 100% on Wayland

Even with the fix, the keyboard "grab" through XWayland isn't total. On KDE Plasma the KWin compositor honours most of it, but the Super / Meta key (the ⊞ key) can still pop out to the desktop, and a few compositor shortcuts may leak. In practice, for a supervised toddler, it's fine — you just dismiss it if they hit it.

If you want a rock-solid, total lock, log into an X11 session instead of Wayland: at the login screen, click the session/gear icon and choose "Plasma (X11)" (or your desktop's X11 option). Under X11, bambam grabs the keyboard completely — nothing leaks — and you don't even need the workarounds above. Switch back to Wayland afterwards for everyday use.

TL;DR

sudo apt install bambam
SDL_VIDEODRIVER=x11 bambam --wayland-ok   # type "quit" to exit

Happy mashing. 👶⌨️🌈


This gist was generated by Claude Code. Please verify any information before relying on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment