Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gtk-launch? #174

Open
probonopd opened this issue Jun 27, 2016 · 8 comments
Open

Use gtk-launch? #174

probonopd opened this issue Jun 27, 2016 · 8 comments

Comments

@probonopd
Copy link
Member

Launch specified application by its desktop file info.
Might result in icon being shown in Unity dock properly.
To be tested on other distributions.

To launch from the "outside"; e.g., from the desktopintegration wrapper:
gtk-launch appimagekit-leafpad

@develar
Copy link
Contributor

develar commented Jul 5, 2016

Yeah, app icon is shown only if run from "Spotlight" (ubuntu - Search this computer). And no icon if run as click on image or terminal. Will try gtk-launch.

@develar
Copy link
Contributor

develar commented Jul 5, 2016

If I understand correctly, if we will use gtk-launch in the desktopintegration wrapper, image will be mounted twice — because gtk-launch will execute image again.

@probonopd
Copy link
Member Author

probonopd commented Jul 5, 2016

Yes we still need to wrap our head around that. Probably the correct way would be for the desktopintegration script to install the desktop integration, and then not launch the payload app but unmount the AppImage and then execute gtk-launch on the just-installed desktop file. Only I don't know how to do this (yet)...

@develar
Copy link
Contributor

develar commented Jul 6, 2016

then not launch the payload app but unmount the AppImage and then execute gtk-launch on the just-installed desktop file. Only I don't know how to do this (yet)...

And it is a dirty hack. I am not Linux user. On OS X I always use Spotlight/Dock to run app. On Linux — if user will use image (click) to run — boot time will be increased because of this solution. Well, yeah, I am not Linux expert and also don't know is there better solution.

Only if we will implement this solution in the runtime to avoid mount.

@probonopd
Copy link
Member Author

Looks like we might need to develop the Linux equivalent of macOS LaunchServices ;-)

@probonopd
Copy link
Member Author

Let's not forget that there is gtk-launch, but KDE uses something else, as does XFCE, so we would also have to have a good look at how xdg-open deals with those.

@probonopd
Copy link
Member Author

Let's really make sure this also works on non-gtk distros; at least it should fall back to the current behavior if there is no gtk-launch installed.

@probonopd
Copy link
Member Author

probonopd commented Oct 9, 2016

Implemented a bare-bones replacement for gtk-launch.

It can launch AppImages with icon like this: ./launch /home/me/.local/share/applications/appimagekit-terminix.desktop. Possibly it can also be used inside the AppImage by AppRun... to be investigated.

On Ubuntu 12.04:

/*
Can be compiled on Ubuntu 12.04 with
sudo apt-get install glib2.0-dev libgtk2.0-dev
gcc launch.c -o launch $(pkg-config --cflags glib-2.0) $(pkg-config --libs glib-2.0) \
$(pkg-config --cflags gio-unix-2.0) $(pkg-config --libs gio-unix-2.0) \
$(pkg-config gtk+-2.0 --libs) $(pkg-config gtk+-2.0 --cflags)
*/

#include <stdio.h>
#include <unistd.h>
#include <string.h>

#include <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gio/gdesktopappinfo.h>

static gchar **args = NULL;

int
main (int argc, char *argv[])
{
    GDesktopAppInfo *info;
    if (! argv[1]){
        fprintf(stderr, "USAGE: %s DESKTOPFILE\n", argv[0]);
        return 1;
    }
    gtk_init(&argc, &argv);
    char *filename;
    const gchar *file = NULL;
    char buf[PATH_MAX];
    memset(buf, 0, sizeof(buf));
    snprintf(buf, sizeof(buf) - 1, "%s", argv[1]);
    GAppLaunchContext *context;
    context = g_app_launch_context_new();
    GDesktopAppInfo *appinfo = g_desktop_app_info_new_from_filename(buf);
    if (appinfo)
        g_app_info_launch((GAppInfo *)appinfo, NULL, context, NULL);
    return 0;
}

results in not much less:

root@host:/# ldd ./launch 
    linux-vdso.so.1 =>  (0x00007ffede8d1000)
    libgio-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0 (0x00007fe5d042f000)
    libgtk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 (0x00007fe5cfdf4000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe5cfbd6000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe5cf816000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe5cf521000)
    libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fe5cf2d1000)
    libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007fe5cf0cd000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fe5ceeb6000)
    libselinux.so.1 => /lib/x86_64-linux-gnu/libselinux.so.1 (0x00007fe5cec96000)
    libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007fe5cea7a000)
    libgdk-x11-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (0x00007fe5ce7c8000)
    libpangocairo-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0 (0x00007fe5ce5bb000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007fe5ce286000)
    libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007fe5ce080000)
    libatk-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libatk-1.0.so.0 (0x00007fe5cde5d000)
    libcairo.so.2 => /usr/lib/x86_64-linux-gnu/libcairo.so.2 (0x00007fe5cdb9f000)
    libgdk_pixbuf-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007fe5cd97f000)
    libpangoft2-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpangoft2-1.0.so.0 (0x00007fe5cd754000)
    libpango-1.0.so.0 => /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0 (0x00007fe5cd50b000)
    libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007fe5cd2d5000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe5ccfd8000)
    /lib64/ld-linux-x86-64.so.2 (0x000055fbb61ed000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007fe5ccd9b000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe5ccb93000)
    libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007fe5cc98a000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fe5cc786000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007fe5cc574000)
    libXrender.so.1 => /usr/lib/x86_64-linux-gnu/libXrender.so.1 (0x00007fe5cc36a000)
    libXinerama.so.1 => /usr/lib/x86_64-linux-gnu/libXinerama.so.1 (0x00007fe5cc167000)
    libXi.so.6 => /usr/lib/x86_64-linux-gnu/libXi.so.6 (0x00007fe5cbf56000)
    libXrandr.so.2 => /usr/lib/x86_64-linux-gnu/libXrandr.so.2 (0x00007fe5cbd4e000)
    libXcursor.so.1 => /usr/lib/x86_64-linux-gnu/libXcursor.so.1 (0x00007fe5cbb44000)
    libXcomposite.so.1 => /usr/lib/x86_64-linux-gnu/libXcomposite.so.1 (0x00007fe5cb940000)
    libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007fe5cb73d000)
    libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fe5cb49f000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007fe5cb281000)
    libpixman-1.so.0 => /usr/lib/x86_64-linux-gnu/libpixman-1.so.0 (0x00007fe5cafea000)
    libpng12.so.0 => /lib/x86_64-linux-gnu/libpng12.so.0 (0x00007fe5cadc1000)
    libxcb-shm.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-shm.so.0 (0x00007fe5cabbe000)
    libxcb-render.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-render.so.0 (0x00007fe5ca9b4000)
    libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fe5ca789000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007fe5ca586000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007fe5ca37f000)

Actually the file itself depends only on

/lib64/ld-linux-x86-64.so.2
libgio-2.0.so.0
libgtk-x11-2.0.so.0
libpthread.so.0
libc.so.6

and the rest are dependencies of the dependencies. So should be reasonable to use.

launch.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants