Score:0

VNC on Ubuntu 22.04 - DBUS_SESSION_BUS_ADDRESS unset; can't run "dconf reset"

in flag

I want to reset my Ubuntu 22.04 desktop settings over a vnc terminal (Uubntu 22.04 is running TigerVNC.) I followed instructions at https://linuxhint.com/ubuntu_dock_settings/ and backed up the current desktop settings using

$ dconf dump / > backup.txt

However, when I try to reset the desktop settings using

dconf reset -f /

I get the following error.

error: Error spawning command line “dbus-launch --autolaunch=c7014a22ae9647b69f20ea2bbc28bec4 --binary-syntax --close-stderr”: Child process exited with code 1

I noticed that my ~/.vnc/xstartup file included unset DBUS_SESSION_BUS_ADDRESS (I copied the xstartup file from https://bytexd.com/how-to-install-configure-vnc-server-on-ubuntu/). Here are the contents of the xstarup file.

#!/bin/sh 

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

gnome-session

I commented out the unset DBUS_SESSION_BUS_ADDRESS, restarted the vncserver, and reconnected from a vnc client. But DBUS_SESSION_BUS_ADDRESS is still unset / undefined. I still get the same error when running dconf reset-f / .

Next, I commented out the unset DBUS_SESSION_BUS_ADDRESS line and added the following to the xstartup file just before the gnome-shell invocation and restarted the vncserver.

if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
    eval `dbus-launch --sh-syntax --exit-with-session`
    echo "D-BUS per-session daemon address is: \
    $DBUS_SESSION_BUS_ADDRESS"
fi

However, DBUS_SESSION_BUS_ADDRESS is still unset. Still the same error from the dconf reset -f / command.

At this point, I entered the following command in a terminal over vnc.

dbus-launch --sh-syntax --exit-with-session

This command responded with the following.

DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-wSUKXx6r0W,guid=3d557317b8f0a468242814d8636956e6';
export DBUS_SESSION_BUS_ADDRESS;
DBUS_SESSION_BUS_PID=4709;

However, DBUS_SESSION_BUS_ADDRESS is still unset / undefined in the terminal. And I still can't reset Ubuntu desktop settings.

Any ideas?

AC-DC avatar
in flag
Running "dconf reset -f /" on the physical host worked fine and reset the gnome desktop settings to defaault (DBUS_SESSION_BUS_ADDRESS was undefined on a terminal window on the host machine as well but the dconf command completed without errors). However, this had no effect on the gnome desktop settings for VNC. How can I reset my VNC based gnome desktop to default settings?
Score:2
ec flag
EML

The xstartup is wrong - all these web tutorials use an ancient version which messes up DBUS_SESSION_BUS_ADDRESS, snap, and so on. Just delete your xstartup: the default on 22.04 is fine (/etc/X11/Xtigervnc-session). When you've got a terminal:

 $ echo $DBUS_SESSION_BUS_ADDRESS
unix:path=/run/user/1000/bus

(assuming you're UID 1000). If it's not working, you'll get something more complicated.

Ludwig avatar
it flag
Do you have any further reference for this? You seem to be right that something changed fundamentally with the use of SNAPs. However, (at least in my case) also with the "default" VNC startup, `DBUS_SESSION_BUS_ADDRESS` is set to `/tmp/...` as described above. Do you know any tutorial that describes how to correctly deal with this in 22.04?
ec flag
EML
For general background on the Snap/`DBUS_SESSION_BUS_ADDRESS` see [this](https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1951491) bug report. However, this isn't VNC-specific, unless you have a bad `xstartup`. See my comment at #73. When you get VNC running, there are still other issues. The main one is that you're not treated identically to a user who logged in locally, so you don't have some permisisons. I've been seeing this for 20-odd years. I did have a fix for RedHat at some stage, but it would need re-working.
Score:0
lk flag

I got around this issue with this.

su -l username -c "(export DISPLAY=:5; dbus-launch --exit-with-session; vncserver -geometry 1792x899 -depth 24 :5)"

The command "dbus-launch --exit-with-session" sets dbus variables to be specific to the user running vncserver, otherwise it might pick them up from somewhere else or not have them set at all. 



DBUS_SESSION_BUS_PID=31898 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1003/bus

These need to be set correctly or you will get a blank screen or permission denied. For example DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1003/bus Where 1003 is the id of the user.

You also need dbus-x11 or dbus-user-session package installed

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.