Noticing this behavior with thunar / thunar-devel 1.8.4 but NOT with thunar-extended 1.6.16 -- on startup, trying to load any folder will cause Thunar to segfault. thunar-devel 1.8.4-1 linux 5.0.12.arch2-1 wayland 1.17.0-1 xorg-server-xwayland 1.20.4-1 gdb backtrace of coredump: #0 0x00007fc3bcb997db in () at /usr/lib/libX11.so.6 #1 0x00007fc3bcb99b9a in XInternAtom () at /usr/lib/libX11.so.6 #2 0x00007fc3a0fd45cd in twp_provider_get_file_menu_items (menu_provider=<optimized out>, window=<optimized out>, files=<optimized out>) at twp-provider.c:188 #3 0x00007fc3be463e96 in thunarx_menu_provider_get_file_menu_items (provider=0x56113742b890, window=0x561137176450, files=0x561137144740 = {...}) at thunarx-menu-provider.c:123 #4 0x00005611353fea2a in () #5 0x00005611371447a0 in () #6 0x00007fc3bcff0769 in g_value_peek_pointer () at /usr/lib/libgobject-2.0.so.0 #7 0x0000000000000000 in ()
Theoretically this crash should be fixed in Bug #14461 since thunar 1.8.2 Possibly the way to check if wayland is used can be improved. See here: https://git.xfce.org/xfce/thunar/tree/plugins/thunar-wallpaper/twp-provider.c#n129 What happens if you do: export XDG_SESSION_TYPE=wayland thunar -q;thunar Yoi possibly know a better way to check for a running wayland session ?
.. or maybe just echo $XDG_SESSION_TYPE to see if it is already defined as something
Though I wonder if we really need this "gdk_x11_get_default_xdisplay" at all to decide if it is a gnome/xfce session. Instead we could just ignore if it is DESKTOP_TYPE_NAUTILUS or DESKTOP_TYPE_XFCE and attempt to set the new image for both .. to be tested.
Hmm -- it seems this is a bug in Sway not properly exporting the env vars that I have defined in my config. I did echo $XDG_SESSION_TYPE and the response was "tty", despite me having "exec export XDG_SESSION_TYPE=wayland" on startup. Upon manually setting the env var, Thunar now works properly as best as I can tell. But only in that one terminal -- trying to launch Thunar from rofi crashes again. As far as Thunar is concerned, it seems to me that there is still an oversight in the logic -- there are more desktops than gnome or xfce. As for the variables that are set globally by default, there is DISPLAY=:0 which is set for Xwayland compatibility. Attempting to run "thunar --display=:0" loads a working instance of Thunar, albeit without the custom GTK theme I've set. For now, my workaround is to instead set the env variables some other way, e.g. via /etc/environment or by aliasing "sway" to include exporting env vars.
I think ideally there should be a way to detect when a user simply wants to run Thunar without the wallpaper/desktop bits at all. Either by some flag, or through better heuristics.
Created attachment 8496 patch Attached a patch to rely on XDG_CURRENT_DESKTOP instead of wired XInternAtom stuff. This should make it possible to as well actually use the functionallity under wayland. Works fine if XDG_CURRENT_DESKTOP is defined as XFCE .. cannot test for GNOME (let see if somebody reports a bug against it) I as well added some g_error output, so people have a change to see why it does not work. Could you please take a try to set a wallpaper via thunar right-click menu in wayland ? I cannot test that, since I dont run wayland. Think it should work fine now, since there is no more X11 call used.
As far as providing feedback to the user that something is wrong, it might help to detect when XDG_SESSION_TYPE = tty and warn them that the XDG_SESSION_TYPE variable may not be properly set. In any case, as I am using Sway the background capability is handled by swaybg, and Thunar does not even show wallpaper options on right-click. Should it do so? I would think that the wallpaper functionality should be disabled when not applicable. But at the same time, checking for such state should not crash the entire application.
Please check my patch. It does not use XDG_SESSION_TYPE any more. Like that the code should as well work fine for wayland. You will see the wallpaper item in the context menu only, if you right-click some picture. And via wayland only, if you compile thunar from source and apply the patch I provided. ( Since swaybg so far is not supported, you should see an error-message saying so in the console) So if you can, it would be nice if you could compile thunar from source and take a try for the patch. (If possible, I would like to have a wayland tester before pushing this patch)
OK, I've applied the patch and now I see "Set wallpaper" even on Sway/Wayland. Attempting to click it results in a crash with the error message: ``` Failed to set wallpaper: $XDG_CURRENT_DESKTOP is not defined Trace/breakpoint trap (core dumped) ``` Which I assume is what you expected to happen
I can also confirm it no longer crashes on click in my initial environment: - XDG_CURRENT_DESKTOP = (null) - XDG_SESSION_TYPE = tty Likewise for when session type is defined as "wayland" (my original workaround). Seems like the patch works!
Thanks alot for testing ! Uh, actually I did not want to crash thunar on missing support ... will replace all g_error with g_warning calls and than push the fix
Alexander Schwinn referenced this bugreport in commit e3bbdd8dd98898821b961ae1d41827e8b6b3272a Thunar crashes after clicking when XDG_SESSION_TYPE isn't properly set (Bug #15366) - Use $XDG_CURRENT_DESKTOP instead of gdk_x11_get_default_xdisplay to decide which desktop is currently used. https://git.xfce.org/xfce/thunar/commit?id=e3bbdd8dd98898821b961ae1d41827e8b6b3272a
Alexander Schwinn referenced this bugreport in commit 7033e61f02b737acd7e845b296bd73544d2ed644 Thunar crashes after clicking when XDG_SESSION_TYPE isn't properly set (Bug #15366) - Use $XDG_CURRENT_DESKTOP instead of gdk_x11_get_default_xdisplay to decide which desktop is currently used. https://git.xfce.org/xfce/thunar/commit?id=7033e61f02b737acd7e845b296bd73544d2ed644
Fixed on master and 4.14 branch, to be released as thunar 1.8.5 soon