With this command, I'm able to run gedit in sudo and get the menu:
sudo -E gedit
The environment variable that matters is DBUS_SESSION_BUS_ADDRESS.
So you can also get gedit working like this:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GTK_MODULES=$GTK_MODULES DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS gedit
That said, dconf still doesn't work. So it's not possible changing the preferences.
With this command, I'm able to run gedit in sudo and get the menu:
sudo -E gedit
The environment variable that matters is DBUS_SESSION_ BUS_ADDRESS.
So you can also get gedit working like this: $XAUTHORITY GTK_MODULES= $GTK_MODULES DBUS_SESSION_ BUS_ADDRESS= $DBUS_SESSION_ BUS_ADDRESS gedit
pkexec env DISPLAY=$DISPLAY XAUTHORITY=
That said, dconf still doesn't work. So it's not possible changing the preferences.