porridge / bambam

keyboard mashing and doodling game for babies and toddlers
GNU General Public License v3.0
72 stars 36 forks source link

My baby can easily escape this program with XFCE shortcuts #57

Open AlexFolland opened 3 years ago

AlexFolland commented 3 years ago

Observed behavior:

My baby has successfully pressed the following XFCE shortcuts, which have inadvertently escaped this game:

These shortcuts are very easy to access, especially since they are both near the bottom of the keyboard, which is basically all my baby can reach from my chair.

Expected behavior:

Window manager keyboard shortcuts are expected to be disabled until the game is exited.

Alternatively, the program is expected to be able to be run directly from a TTY and start a display server like gamescope or something like that on its own, so that no window manager keyboard shortcuts are available.

Additional fluff:

Thanks for this FOSS. I have been looking for something like this, that allows my baby to just bash the keyboard and see what happens. My dad wrote a game in the 80s for DOS called "funkeys" for me and my brother to bash the keyboard way back then that drew random-colored and random-sized shapes on the screen, and played a random PC speaker tone with each keystroke, but he unfortunately lost the source code for that. Now that I have a kid, I wanted to give the same kind of introduction to computer keyboards.

~I wish there was sound in it. Even a random-pitch super short beep with each keystroke would be cool. Obviously no pressure though. It's FOSS, after all.~ Edit: Apparently I was experiencing an easyeffects + pipewire issue that prevented all sound the first time I tried this program. Excuse me. There is sound!

porridge commented 3 years ago

Hi @AlexFolland bambam does try to grab the keyboard, but apparently this does not work completely in some environments. What you describe sounds like yet another case of what I described in the man page. Can you confirm that you are not running under Wayland? Would you mind pasting the output of env | sort from you XFCE session (after pruning any sensitive information).

AlexFolland commented 3 years ago

Here! Thanks for checking.

terminal log ``` [alex@alex-pc ~]$ env | sort COLORTERM=truecolor DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DESKTOP_SESSION=xfce DISPLAY=:0.0 ftp_proxy= GRADLE_HOME=/usr/share/java/gradle GTK3_MODULES=xapp-gtk3-module:xapp-gtk3-module GTK_MODULES=canberra-gtk-module:canberra-gtk-module HG=/usr/bin/hg HOME=/home/alex http_proxy= https_proxy= LANG=en_US.UTF-8 LC_ADDRESS=en_CA.UTF-8 LC_IDENTIFICATION=en_CA.UTF-8 LC_MEASUREMENT=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_NAME=en_CA.UTF-8 LC_NUMERIC=en_CA.UTF-8 LC_PAPER=en_CA.UTF-8 LC_TELEPHONE=en_CA.UTF-8 LC_TIME=en_CA.UTF-8 LIBVA_DRIVER_NAME=vdpau LOGNAME=alex LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36: MAIL=/var/spool/mail/alex MANGOHUD=1 MOTD_SHOWN=pam MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins PAM_KWALLET5_LOGIN=/run/user/1000/kwallet5.socket PANEL_GDK_CORE_DEVICE_EVENTS=0 PATH=/home/alex/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl://home/alex/work/ecg/android-studio/bin PWD=/home/alex QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1 QT_QPA_PLATFORMTHEME=gtk2 SESSION_MANAGER=local/alex-pc:@/tmp/.ICE-unix/1982,unix/alex-pc:/tmp/.ICE-unix/1982 SHELL=/bin/bash SHLVL=0 socks_proxy= SSH_AUTH_SOCK=/run/user/1000/keyring/ssh TERM=xterm-256color USER=alex _=/usr/bin/env VDPAU_DRIVER=nvidia VTE_VERSION=6402 WINDOWID=34078723 XAUTHORITY=/home/alex/.Xauthority XDG_CONFIG_DIRS=/etc/xdg XDG_CURRENT_DESKTOP=XFCE XDG_DATA_DIRS=/usr/local/share:/usr/share XDG_MENU_PREFIX=xfce- XDG_RUNTIME_DIR=/run/user/1000 XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0 XDG_SEAT=seat0 XDG_SESSION_CLASS=user XDG_SESSION_DESKTOP=XFCE XDG_SESSION_ID=2 XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session1 XDG_SESSION_TYPE=x11 XDG_VTNR=1 YAOURT_COLORS=nb=1:pkg=1:ver=1;32:lver=1;45:installed=1;42:grp=1;34:od=1;41;5:votes=1;44:dsc=0:other=1;35 [alex@alex-pc ~]$ ```
porridge commented 2 years ago

FWIW, I added a "bambam session" mode in v1.2.0 where you can install a .desktop file which lets you run a session with just bambam in it. This way prevents this and any other ways to escape the program (as long as your other concurrent sessions are locked with a password).

pdecat commented 2 years ago

FWIW, I added a "bambam session" mode in v1.2.0 where you can install a .desktop file which lets you run a session with just bambam in it. This way prevents this and any other ways to escape the program (as long as your other concurrent sessions are locked with a password).

This new addition is awesome, thanks @porridge!

Edit: mouse clicks are working in the dedication session, but mouse pointer does not show, and keyboard presses do not respond at all (quit does not work, no sound, no sprites are displayed).

porridge commented 7 months ago

@pdecat sorry, I only noticed your edit now. Can you please let me know what environment (hardware, distribution, display manager) you tried the dedicated session in? I did test it in a few display managers, and it worked without issues. 😞

pdecat commented 7 months ago

Hi @porridge,

@pdecat sorry, I only noticed your edit now.

No problem :)

Can you please let me know what environment (hardware, distribution, display manager) you tried the dedicated session in?

It was probably with Xorg / AMD Radeon / Intel Core i7 on Ubuntu 22.04 (or maybe 22.10 beta).

I did test it in a few display managers, and it worked without issues. 😞

Let's consider this resolved then :)

porridge commented 7 months ago

Can you please let me know what environment (hardware, distribution, display manager) you tried the dedicated session in?

It was probably with Xorg / AMD Radeon / Intel Core i7 on Ubuntu 22.04 (or maybe 22.10 beta).

Thanks, and which display manager that was? Gdm, kdm, something else?

pdecat commented 7 months ago

GDM3 most certainly.

porridge commented 7 months ago

Hm, I just tried it under gdm3 on current Debian stable, and:

So there is something fishy going on...

porridge commented 7 months ago

Looks like GDM hides mouse cursor when starting a session, and pygame assumes it's on. But I was able to make it appear by flipping pygame.mouse.set_visible back and forth. I'll make the change soon.

As for sound, it seems that we just need to wait a little for the sound service to be started by systemd. I'll see if I can do it in a reliable way, that avoids a race.

Although I didn't manage to reproduce it, I suspect the problem with non-working keyboard might be similar to the missing sound issue - if we initialize pygame too soon, "something" that makes keyboard work might not be running yet 🤔