mviereck / x11docker

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

KDE plasma global menu integration with --hostdbus #78

Closed 4O4 closed 6 years ago

4O4 commented 6 years ago

Hi, awesome project! I'm just wondering if it is possible to show app's menu in host OS global menu (e.g. the default one in KDE Plasma) for more seamless experience? Maybe some tricks with --hostdbus and some libraries inside the container? I tried to experiment a bit by myself but I don't know too much about internals of global menu handling yet, I'll appreciate any help.

mviereck commented 6 years ago

Do you mean the regular application menu? You can create a desktop starter icon with option --starter, e.g.

x11docker --starter --clipboard x11docker/lxde leafpad

Move this desktop file in your home folder to ~./local/share/applications. It should appear in your global menu.


Edit: You can edit the .desktop file with a text editor to adjust it.

#!/usr/bin/xdg-open
[Desktop Entry]
# x11docker desktop file
Type=Application
Name=x11docker-lxde leafpad
Exec=x11docker   --clipboard -- 'x11docker/lxde' 'leafpad'
Icon=x11docker
Comment=
Categories=System
Keywords=docker x11docker x11docker lxde leafpad 
TryExec=x11docker   --clipboard -- 'x11docker/lxde' 'leafpad'

The most interesting lines are Name=, Icon= and Categories=. Some desktop environment provide an editor. E.g. on Xfce i can right-click the file and change icon and name.

4O4 commented 6 years ago

No, what you're talking about is an application launcher :) I mean the macOS-like global menu usually docked in panel at the top of the screen

image

mviereck commented 6 years ago

Oh, ok. I've seen something similar once in Unity desktop, but I did not use Unity.

Try out if any combination of --hostdbus, --hostnet or --hostipc helps. Though, I would assume it is a feature of the window manager KWin and should work ootb for all applications without configuring them.

4O4 commented 6 years ago

Including all of these flags was my second thought but it is apparently not enough :( It doesn't work out of the box either. There are two scenarios where the menubar stays visible inside the application instead of being hidden there and displayed in global menu instead:

I don't think that it's possible to overcome the first case, because there are two different users and they don't share d-bus session.

I hope however, that there is some workaround for second option since all the x11docker stuff seems to be running as current user and it's possible to share dbus. But as I said - I don't have enough knowledge so I maybe totally wrong.

mviereck commented 6 years ago

I hope however, that there is some workaround for second option since all the x11docker stuff seems to be running as current user and it's possible to share dbus.

Currently --hostdbus only shares the user session dbus socket, but not the dbus system socket. Try to add --hostdbus --sharedir /run/dbus/system-bus-socket. Also try with different applications. I'd assume that QT5 applications will integrate better than GTK applications. x11docker/plasma konsole is worth a try, or x11docker/lxqt pcmanfm-qt.

4O4 commented 6 years ago

Awesome, it works both with and without --sharedir option (--hostdbus is enough)! I guess it's a matter of the libs installed in the plasma image then

mviereck commented 6 years ago

Awesome, it works both with and without --sharedir option (--hostdbus is enough)! I

Glad to hear that. :-)

I guess it's a matter of the libs installed in the plasma image then

First guesses: Maybe packages qdbus and/or qdbus-qt5. Maybe libqt5widgets5.

mviereck commented 6 years ago

There is a piece of code in x11docker that may block the global menu integration. Indeed it is surprising that it worked for x11docker/plasma konsole and --hostdbus at all.

At line 4000 x11docker sets some environment variables to avoid possible xpra issues:

  echo   "  echo 'export UBUNTU_MENUPROXY= QT_X11_NO_NATIVE_MENUBAR=1 MWNOCAPTURE=true MWNO_RIT=true MWWM=allwm'"

You could remove that line (or at least QT_X11_NO_NATIVE_MENUBAR=1) and try out further if some more applications integrate into the global menu.

4O4 commented 6 years ago

I'm guessing these might be some legacy or Ubuntu-specific variables and I am using arch-based distro which maybe doesn't care about them. Anyway I'm gonna test it when I have some spare time. Thank you for your help!

On Thu, 27 Sep 2018, 22:33 mviereck, notifications@github.com wrote:

There is a piece of code in x11docker that may block the global menu integration. Indeed it is surprising that it worked for x11docker/plasma konsole and --hostdbus at all.

At line 4000 x11docker sets some environment variables to avoid possible xpra issues:

echo " echo 'export UBUNTU_MENUPROXY= QT_X11_NO_NATIVE_MENUBAR=1 MWNOCAPTURE=true MWNO_RIT=true MWWM=allwm'"

You could remove that line (or at least QT_X11_NO_NATIVE_MENUBAR=1) and try out further if some more applications integrate into the global menu.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mviereck/x11docker/issues/78#issuecomment-425233040, or mute the thread https://github.com/notifications/unsubscribe-auth/AEE6AxqJwwy9U3jEgVrLdOLqXIXyjHT8ks5ufTYzgaJpZM4W0vKi .