I want to solve the following use case: my wife and me (= two separate linux users) want to use THE SAME VirtualBox Windows10 virtual machine. So my idea is to have all VirtualBox settings under the user “vmuser” and start VirtualBox always in the vmuser environment.
Then in the folder /home/vmuser all the VirtualBox settings are set up.
On every user desktop I added a desktop file “VirtualBox.desktop” with the content:
[Desktop Entry] Comment= Exec=mate-terminal -- /bin/su vmuser -w QT_QPA_PLATFORM_THEME,DISPLAY,XDG_RUNTIME_DIR -c /usr/local/bin/startVirtualBox.sh GenericName=Go virtual Icon=virtualbox MimeType= Name=VirtualBox Path= StartupNotify=true Terminal=true TerminalOptions= Type=Application X-DBUS-ServiceName= X-DBUS-StartupType= X-KDE-SubstituteUID=false X-KDE-Username=`
Clicking on this icon then launches the file
/usr/local/bin/startVirtualBox.sh. The “-w” is for not replacing existing environment variables. I use “mate-terminal” because it is starting faster on my machine compared to “gome-terminal” but your mileage may vary.
For some to me yet unknown reason (I think the issue is the /bin/sh at the beginning but it does not work without) I need to define the environment variables this way:
#!/bin/sh QT_X11_NO_MITSHM=1 DISPLAY=$ DISPLAY XAUTHORITY=$ XAUTHORITY XDG_RUNTIME_DIR=$ XDG_RUNTIME_DIR export QT_X11_NO_MITSHM export DISPLAY export XAUTHORITY export XDG_RUNTIME_DIR /usr/bin/VirtualBox
This solution works as expected despite some error messages during the start of VirtualBox in the extra console window:
Qt WARNING: QStandardPaths: wrong ownership on runtime directory /run/user/1000, 1000 instead of 1002 Qt WARNING: Qt: Session management error: None of the authentication protocols specified are supported
The user runtime directory is under control of the user who clicks the desktop icon (id=1000) and the VirtualBox process starts under the vmuser (user id = 1002). Ok.
But does anybody know how to get rid of this?