Using argv[0] does not work with AppImages: it contains the path to
where the AppImage was called from, and not the path where the
executable is running.
This solution uses the whereami package from:
https://github.com/gpakosz/whereami
view_dir_tree.c \
view_dir_tree.h \
view_file.h \
view_dir_tree.c \
view_dir_tree.h \
view_file.h \
+ whereami.c \
+ whereami.h \
window.c \
window.h \
lua.c \
window.c \
window.h \
lua.c \
#include "histogram.h"
#include "pixbuf_util.h"
#include "glua.h"
#include "histogram.h"
#include "pixbuf_util.h"
#include "glua.h"
#ifdef HAVE_CLUTTER
#include <clutter-gtk/clutter-gtk.h>
#ifdef HAVE_CLUTTER
#include <clutter-gtk/clutter-gtk.h>
{
gchar *dirname;
gchar *tmp;
{
gchar *dirname;
gchar *tmp;
- gchar **env;
-
- env = g_get_environ();
+ gint length;
+ gchar *path;
- if (argv[0][0] == G_DIR_SEPARATOR)
- {
- gq_executable_path = g_strdup(argv[0]);
- }
- else
- {
- gq_executable_path = g_build_filename(g_environ_getenv(env, "PWD"), argv[0], NULL);
- }
+ length = wai_getExecutablePath(NULL, 0, NULL);
+ path = (gchar *)malloc(length + 1);
+ wai_getExecutablePath(path, length, NULL);
+ path[length] = '\0';
+ gq_executable_path = g_strdup(path);
dirname = g_path_get_dirname(gq_executable_path); // default is /usr/bin/
gq_prefix = g_path_get_dirname(dirname);
dirname = g_path_get_dirname(gq_executable_path); // default is /usr/bin/
gq_prefix = g_path_get_dirname(dirname);
g_free(tmp);
g_free(dirname);
g_free(tmp);
g_free(dirname);
}
gint main(gint argc, gchar *argv[])
}
gint main(gint argc, gchar *argv[])