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 bambamBut 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.
-
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. -
It refuses to run on purpose. Newer
bambamversions 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_DISPLAYorXDG_SESSION_TYPE=waylandenvironment variables.)
Two changes, together:
- 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.) - Pass the
--wayland-okflag — an intentionally undocumented option that skips the refusal guard.
Quick test from a terminal:
SDL_VIDEODRIVER=x11 bambam --wayland-okTo 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.
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/applicationsEven 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.
sudo apt install bambam
SDL_VIDEODRIVER=x11 bambam --wayland-ok # type "quit" to exitHappy mashing. 👶⌨️🌈
This gist was generated by Claude Code. Please verify any information before relying on it.