From aaaf79d0f749e0dbf2b68422f93ee66142052d84 Mon Sep 17 00:00:00 2001 From: Scoopta Date: Thu, 21 May 2020 15:18:26 -0700 Subject: [PATCH] PrefersNonDefaultGPU is now respected when launching a non-primary action --- modes/drun.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modes/drun.c b/modes/drun.c index 5bc2127..4da080e 100644 --- a/modes/drun.c +++ b/modes/drun.c @@ -404,6 +404,13 @@ static void launch_done(GObject* obj, GAsyncResult* result, gpointer data) { exit(1); } +static void set_dri_prime(GDesktopAppInfo* info) { + bool dri_prime = g_desktop_app_info_get_boolean(info, "PrefersNonDefaultGPU"); + if(dri_prime) { + setenv("DRI_PRIME", "1", true); + } +} + void wofi_drun_exec(const gchar* cmd) { GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(cmd); if(G_IS_DESKTOP_APP_INFO(info)) { @@ -412,10 +419,7 @@ void wofi_drun_exec(const gchar* cmd) { printf("%s\n", g_app_info_get_commandline(G_APP_INFO(info))); exit(0); } else { - bool dri_prime = g_desktop_app_info_get_boolean(info, "PrefersNonDefaultGPU"); - if(dri_prime) { - setenv("DRI_PRIME", "1", true); - } + set_dri_prime(info); g_app_info_launch_uris_async(G_APP_INFO(info), NULL, NULL, NULL, launch_done, (gchar*) cmd); } } else if(strrchr(cmd, ' ') != NULL) { @@ -428,6 +432,7 @@ void wofi_drun_exec(const gchar* cmd) { printf("%s\n", g_app_info_get_commandline(G_APP_INFO(info))); fprintf(stderr, "Printing the command line for an action is not supported\n"); } else { + set_dri_prime(info); g_desktop_app_info_launch_action(info, action, NULL); utils_sleep_millis(500); }