runtime.c: Set `XDG_DATA_DIRS` if it is empty to begin with
I have a GTK# mono APP, in ubuntu and debian runs without problems. However in manjaro 17.0.2 I have problems with GTK theme, get errors loading png icons.
** (SerialTerminal:1190): WARNING **: Pixbuf theme: Cannot load pixmap file /usr/share/themes/Vertex-Maia-Dark/gtk-2.0/Entry/entry-border-fill.png: No se pudo reconocer el formato de imagen del archivo «/usr/share/themes/Vertex-Maia-Dark/gtk-2.0/Entry/entry-border-fill.png»
(SerialTerminal:1190): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_width: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
(SerialTerminal:1190): GdkPixbuf-CRITICAL **: gdk_pixbuf_get_height: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
** (SerialTerminal:1190): WARNING **: Invalid borders specified for theme pixmap:
/usr/share/themes/Vertex-Maia-Dark/gtk-2.0/Entry/entry-border-fill.png,
borders don't fit within the image
runing the application directly whitout create appimage load the icons correctly, so the problem is the XDG_DATA_DIRS, in manajro this variable is not set so when AppRun loader set the XDG_DATA_DIRS put only one path in the variable, and the icons can't be loaded.
adding
export XDG_DATA_DIRS=$(printenv XDG_DATA_DIRS):/usr/local/share:/usr/share
to my app bash script solves de problem.
However I thing that the AppRun loader must set correctly de XDG_DATA_DIRS.
https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
As you can see AppRun.c appends the path inside the AppImage to the path the system provides. I think the bug here is that Manjaro does not set the variable.
https://github.com/AppImage/AppImageKit/blob/ed13661f5606ee89f67b4aca3934c380964b05cc/AppRun.c#L172-L173
But you can use your own AppRun bash script instead of AppRun.c.
Closing it due inactivity. Reopen if required.
I guess we need to set some XDG_DATA_DIRS initial value if it is empty to begin with.
Then, all XDG vars need to be set. And we cannot guarantee that this will work. It might even break.
I think this counts as "you need to write an AppRun to solve this", and would rather document when and how to write an AppRun script on https://docs.appimage.org.
Why not set all XDG variables to their default values in case they are empty?
What "default values"? If any, you need to append to the existing values.
For example, XDG_DATA_DIRS=/usr/share might be a sane default that we could append to, in case the variable was entirely unpopulated before.
Is that relative to the AppDir?
No. Which is why I wrote that we should append our (relative) path to that.
We shouldn't invent defaults outside the scope of the AppImage. Especially since there's default values specified by XDG. Those directories are part of that.
https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html:
$XDG_DATA_DIRS defines the preference-ordered set of base directories to search for data files in addition to the $XDG_DATA_HOME base directory. The directories in $XDG_DATA_DIRS should be seperated with a colon ':'.
If $XDG_DATA_DIRS is either not set or empty, a value equal to /usr/local/share/:/usr/share/ should be used.
From https://appimage-builder.readthedocs.io/en/latest/examples/gimp_path_mapping.html or in https://github.com/AppImageCrafters/AppRun/blob/master/docs/USAGE.md#recommended-environment-entries, it uses this:
XDG_DATA_DIRS: $APPDIR/share:$XDG_DATA_DIRS