g_app_info_launch_uris_async() is now used for drun mode

This commit is contained in:
Scoopta 2019-09-11 21:00:26 -07:00
parent 26107c8ee5
commit 13f67facfb

View File

@ -362,6 +362,16 @@ static void* do_drun(void* data) {
return NULL; return NULL;
} }
static void drun_launch_done(GObject* obj, GAsyncResult* result, gpointer data) {
if(g_app_info_launch_uris_finish(G_APP_INFO(obj), result, NULL)) {
exit(0);
} else {
char* cmd = data;
fprintf(stderr, "%s cannot be executed\n", cmd);
exit(1);
}
}
static void execute_action(char* mode, const gchar* cmd) { static void execute_action(char* mode, const gchar* cmd) {
char* cache_path = get_cache_path(mode); char* cache_path = get_cache_path(mode);
struct wl_list lines; struct wl_list lines;
@ -415,10 +425,7 @@ static void execute_action(char* mode, const gchar* cmd) {
} else if(strcmp(mode, "drun") == 0) { } else if(strcmp(mode, "drun") == 0) {
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(cmd); GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(cmd);
if(G_IS_DESKTOP_APP_INFO(info)) { if(G_IS_DESKTOP_APP_INFO(info)) {
const char* exec = g_app_info_get_executable(G_APP_INFO(info)); g_app_info_launch_uris_async(G_APP_INFO(info), NULL, NULL, NULL, drun_launch_done, (gchar*) cmd);
execlp(exec, exec, NULL);
fprintf(stderr, "%s cannot be executed\n", exec);
exit(errno);
} else { } else {
fprintf(stderr, "%s cannot be executed\n", cmd); fprintf(stderr, "%s cannot be executed\n", cmd);
exit(1); exit(1);