Xpra-org / xpra

Persistent remote applications for X11; screen sharing for X11, MacOS and MSWindows.
https://xpra.org/
GNU General Public License v2.0
1.96k stars 169 forks source link

Linux gsettings sync support #3683

Open knackstedt opened 1 year ago

knackstedt commented 1 year ago

Is your feature request related to a problem? Please describe. I want xpra applications to inherit the gnome theme when they are launched.

Describe the solution you'd like Xpra syncs the GTK theme with the user running the xpra process.

Describe alternatives you've considered It might be possible to use some CLI argument to achieve this, though I don't know what that might be.

Additional context I can help test/debug if necessary.

totaam commented 1 year ago

We probably have to use a regular expression / list to match which settings are synced.

@knackstedt can you verify that this does what you want (assuming that you run a gnome desktop):


First bit of bad news: the Gio bindings for this feature are buggy and querying the wrong key can crash the interpreter!

$ python3
Python 3.10.7 (main, Sep  7 2022, 00:00:00) [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from gi.repository import Gio
>>> source = Gio.SettingsSchemaSource.get_default()
>>> x=source.lookup("org.gnome.desktop.interface", True)
>>> x.get_key("name")

(process:2848795): GLib-GIO-ERROR **: 21:17:39.360: Settings schema 'org.gnome.desktop.interface' does not contain a key named 'name'
Trace/breakpoint trap (core dumped)

I since found many other ways to completely crash the process.
This is not very developer friendly..

k = x.get_key("gtk-theme")
k.get_default_value()
GLib.Variant('s', 'Adwaita')
k.get_default_value().dup_string()
('Adwaita', length=7)

Not sure we want the "default value" but that's all we have access to here?

knackstedt commented 1 year ago

When I run gsettings get org.gnome.desktop.interface gtk-theme i get 'Pop-dark' back. I'm not quite sure if this is what you meant, but I launched a TTY with the client XPRA UI and ran both the get and set. The get returned pop-dark, and launching GTK apps after running the set didn't have any visible effects.

P.S. I am very familiar with PCRE and will offer myself to help if you want. I have previously written a regex syntax highlighter and validator :)

totaam commented 1 year ago

and launching GTK apps after running the set didn't have any visible effects.

Then it must be getting the theme from somewhere else... Until we figure this out, there's not much we can do.

knackstedt commented 1 year ago

Further investigation notes:

Launching an app with the command line GTK_THEME='Pop-dark' gedit does start it in dark mode. Setting GTK_THEME='Pop-dark' as an environment variable before launching an application doesn't appear to make a difference when starting apps in xpra.

Running dconf read /org/gnome/desktop/interface/gtk-theme also yields Pop-dark for me.

I also ran a comparison of environment variables between running an app through xpra and normally. This is a list of the differences (before is non-xpra, after is launched with xpra)

+CHROME_DESKTOP=code-url-handler.desktop
+CKCON_X11_DISPLAY=:0
+CLUTTER_IM_MODULE=xim
+COLORTERM=truecolor
-DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
-DESKTOP_SESSION=pop
-DESKTOP_STARTUP_ID=gnome-shell/Calculator/3895-4-pop-os_TIME0
+DISABLE_IMSETTINGS=1
+GDK_BACKEND=x11
+GDK_SCALE=1
+GTK_CSD=0
-GDMSESSION=pop
~GTK_IM_MODULE=xim
+IMSETTINGS_MODULE=none
+LESSCLOSE=/usr/bin/lesspipe %s %s
+LESSOPEN=| /usr/bin/lesspipe %s
+MWNOCAPTURE=true
+MWNO_RIT=true
+MWWM=allwm
+NO_AT_BRIDGE=1
+ORIGINAL_XDG_CURRENT_DESKTOP=pop:GNOME
+QT4_IM_MODULE=xim
+QT_IM_MODULE=xim
+QT_QPA_PLATFORM=xcb
+QT_X11_NO_NATIVE_MENUBAR=1
-SESSION_MANAGER=local/pop-os:@/tmp/.ICE-unix/3855,unix/pop-os:/tmp/.ICE-unix/3855
~XDG_CURRENT_DESKTOP=Xpra
~XMODIFIERS=@im=none
+XPRA_LOG_DIR=/run/user/1000/xpra
+XPRA_SERVER_SOCKET=/run/user/1000/xpra/pop-os-0

This makes me think a possible solution is to detect if the desktop is running Gnome, run gsettings get org.gnome.desktop.interface gtk-theme to get the theme, then launching apps with the environment variable GTK_THEME='Pop-dark' would work -- though i'm not sure that this is the ideal solution.

totaam commented 1 year ago

I don't understand why these applications are not honouring the gsetttings, surely that would be the way to go.

BTW, your xpra session should have a valid DBUS_SESSION_BUS_ADDRESS - why is it missing?

knackstedt commented 1 year ago

dbus fails to launch when I start xpra, not sure if it's because I'm missing a dependency or some other reason. Basic xpra functionality isn't impaired even with the error message.

2022-11-06 08:27:46,586 dbus-launch failed to start using command 'dbus-launch --sh-syntax --close-stderr':

2022-11-06 08:27:46,586  exit code is 255

I get this xmessage dialog as well image

totaam commented 1 year ago

Perhaps this is related? gsettings or the applications making use of it may need / use / require dbus?

As for Xsession, it must be sourced by your configuration. Note that this is not how things are configured in any of our builds - perhaps you should try on a supported OS to see if things work better there.

knackstedt commented 1 year ago

I tried setting up a vanilla Ubuntu 22.04.1 VM, installed xpra via sources, and it also does not inherit the theme from Gnome. This install didn't report any xsession or dbus errors, but the theme was missing all the same.

xpra v4.4.1-r35

Notably, I wasn't able to drag windows in the html-client for some reason. Probably unrelated to this specific issue.

I also just realized I have xpra v3.1 on my host machine, which might be causing an issue or two

knackstedt commented 1 year ago

I'll also note upgrading xpra to 4.4.1-r35 resolved the dbus and xsession error messages. There was some issue with apt where it used the wrong source to install a much older version of xpra. I deleted that source and upgraded xpra to the latest from the current installation instructions.

totaam commented 1 year ago

I also just realized I have xpra v3.1 on my host machine, which might be causing an issue or two

Yikes!

Notably, I wasn't able to drag windows in the html-client for some reason

The fix for this problem was included in xpra-html5-6.1: https://github.com/Xpra-org/xpra-html5/issues/210

Unfortunately the packages for Ubuntu 22.04 are MIA - will fix that.

totaam commented 1 year ago

dconf looks a bit like the MSWindows registry! I can't find any documentation on what can be stored in there. There are clearly some useful attributes ie:

$ dconf list /org/gnome/desktop/interface/
clock-show-seconds
font-antialiasing
font-hinting
show-battery-percentage
toolkit-accessibility
$ dconf read /org/gnome/desktop/interface/font-antialiasing
'grayscale'

Some things should probably not be synced (ie: system/proxy/http) but others probably should be (ie: org/gnome/shell/weather, org/gnome/gedit/preferences/ui, theme, ...)