AppImageKit icon indicating copy to clipboard operation
AppImageKit copied to clipboard

runtime.c: Set `XDG_DATA_DIRS` if it is empty to begin with

Open Juniorsnet opened this issue 9 years ago • 11 comments

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

Juniorsnet avatar Sep 20 '17 15:09 Juniorsnet

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.

probonopd avatar Sep 21 '17 16:09 probonopd

Closing it due inactivity. Reopen if required.

azubieta avatar Nov 24 '18 00:11 azubieta

I guess we need to set some XDG_DATA_DIRS initial value if it is empty to begin with.

probonopd avatar Nov 24 '18 10:11 probonopd

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.

TheAssassin avatar Nov 24 '18 14:11 TheAssassin

Why not set all XDG variables to their default values in case they are empty?

probonopd avatar Nov 24 '18 14:11 probonopd

What "default values"? If any, you need to append to the existing values.

TheAssassin avatar Nov 24 '18 18:11 TheAssassin

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.

probonopd avatar Nov 24 '18 19:11 probonopd

Is that relative to the AppDir?

TheAssassin avatar Nov 24 '18 19:11 TheAssassin

No. Which is why I wrote that we should append our (relative) path to that.

probonopd avatar Nov 24 '18 19:11 probonopd

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.

TheAssassin avatar Nov 24 '18 20:11 TheAssassin

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

JonathanHuot avatar Oct 02 '22 08:10 JonathanHuot