mviereck / x11docker

Run GUI applications and desktops in docker and podman containers. Focus on security.
MIT License
5.62k stars 378 forks source link

Keyboard and mouse grab issue ? #25

Closed badele closed 6 years ago

badele commented 6 years ago

I trying doing a new docker image (docker-bspwm on arch linux). But i don't know why, the key released don't seem work. I have installed a key-mon for showing the key, not result, but if i use xev, i can see the key code

Have you a good method for debuging the keyboard issue ?

I use

docker build --rm -f docker-bspwm/Dockerfile -t bspwm docker-bspwm
x11docker --xephyr --user=root --pulseaudio --desktop bspwm xterm
#x11docker --xephyr --user=root --pulseaudio --desktop bspwm startx

I have tested this on currently xorg and physical terminal

mviereck commented 6 years ago

I don't see an obvious reason on the first glance. You can try to install a locale in your image. Example for debian, adjust apt-get for arch:

# replace en_US by your desired locale setting, for example de_DE for german.
ENV LANG en_US.UTF-8
RUN echo $LANG UTF-8 > /etc/locale.gen
RUN apt-get install -y locales && update-locale --reset LANG=$LANG

If the issue persists, please run with option --verbose and provide me the output. It is quite long, best way is to store it at https://pastebin.com/.

Edit: Aside from the issue: In your Dockerfile you create a /fakehome/root folder and add some dotfiles. To be more flexible I recommend a solution that does not rely on a specific user or a specifc home folder. Just add your dotfiles to /etc/skel and include this startscript in Dockerfile:

# startscript to copy dotfiles from /etc/skel
# runs either CMD or image command from docker run
RUN echo '#! /bin/sh\n\
[ -e "$HOME/.config" ] || cp -R /etc/skel/. $HOME/ \n\
exec $* \n\
' > /usr/local/bin/start 
RUN chmod +x /usr/local/bin/start 

ENTRYPOINT start
CMD startx
mviereck commented 6 years ago

One possible reason for the issue:

For Xephyr the keyboard mapping is adjusted in xinitrc to match keyboard settings on host with:

setxkbmap -display $Hostdisplay -print | xkbcomp - $Newdisplay

Maybe this command fails somehow and leaves a mess. Can you please show me the output of setxkbmap -display $DISPLAY -print?

badele commented 6 years ago

Hi,

On another computer i progress. The grab it seem working :) Now it show missing a file (my script :) ).

For information, in this computer, x11docker show message, i must run with root user.

This evening, i will test with my home computer. i will inform you

I would take the opportunity to implement the skeleton

mviereck commented 6 years ago

I would like to see the output of setxkbmap -display $DISPLAY -print, maybe it contains a ' or some others chars that cause the issue.

I did a change in x11docker 3.9.4.2 that may avoid the issue.

badele commented 6 years ago

If,

That works :), It's my fault (missing some files), but some points:

The initial skeleton not work for me, i must use echo with -e option, if not, the return feed line is not done and generate error message in container image.

I don"t know why in another computer, i receive this error message "x11docker must run as root", my user account is in the docker group (for two computers)

But, the good news, it works ! :) Good job :).

Can you waiting some days before close this ticket ? I would like do more investigate ?

Thanks

mviereck commented 6 years ago

That works :),

:) Would still like to see the output of setxkbmap -display $DISPLAY -print.

The initial skeleton not work for me, i must use echo with -e option

ok, echo has dozens of different implementations. printf would provide a more general syntax.

I don"t know why in another computer, i receive this error message "x11docker must run as root", my user account is in the docker group (for two computers)

hm, don't know, too. You would need it for --hostuser but not for --user.

Can you waiting some days before close this ticket ? I would like do more investigate ?

I would like to close as the bug itself is fixed. But even in a closed bug you can still comment and I will answer. Also, feel free to open a new ticket for different themes, may they be big or small.

mviereck commented 6 years ago

Inspired by your issue with keymaps I have made an update (V3.9.5) with new option --keymap LAYOUT where you can specify a desired keymap different from autodetected host keymap. For example --keymap fr would set the docker keyboard map to french.

Would still like to see the output of setxkbmap -display $DISPLAY -print, please don't let me starve. ;-)

badele commented 6 years ago

Ourp, i forgot your request for setxkbmap :)

xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(azerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+fr+inet(evdev)" };
    xkb_geometry  { include "pc(pc105)" };
};

It is good for you ? You need more informations

mviereck commented 6 years ago

Thanks! Hm. I thought the output would show something strange that could explain the issues from your first post, but it looks all well.

Before the fix the output of setxkbmap was given with echo to xkbcomp. You found out that echo works different on arch, maybe the reason lies here.

I have some hundred echo in x11docker, maybe I have to review them all and replace with printf. o_O

mviereck commented 6 years ago

Just a note: I found that

ENTRYPOINT start
CMD startx

fails in setups without x11docker. Instead use:

ENTRYPOINT ["/usr/local/bin/start"]
CMD ["startx"]

I've just updated a bunch of my Dockerfiles due to this issue.