PrefersNonDefaultGPU is now respected when launching a non-primary action

This commit is contained in:
Scoopta 2020-05-21 15:18:26 -07:00
parent 37aa2a3b9b
commit aaaf79d0f7

View File

@ -404,6 +404,13 @@ static void launch_done(GObject* obj, GAsyncResult* result, gpointer data) {
exit(1); 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) { void wofi_drun_exec(const gchar* cmd) {
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)) {
@ -412,10 +419,7 @@ void wofi_drun_exec(const gchar* cmd) {
printf("%s\n", g_app_info_get_commandline(G_APP_INFO(info))); printf("%s\n", g_app_info_get_commandline(G_APP_INFO(info)));
exit(0); exit(0);
} else { } else {
bool dri_prime = g_desktop_app_info_get_boolean(info, "PrefersNonDefaultGPU"); set_dri_prime(info);
if(dri_prime) {
setenv("DRI_PRIME", "1", true);
}
g_app_info_launch_uris_async(G_APP_INFO(info), NULL, NULL, NULL, launch_done, (gchar*) cmd); g_app_info_launch_uris_async(G_APP_INFO(info), NULL, NULL, NULL, launch_done, (gchar*) cmd);
} }
} else if(strrchr(cmd, ' ') != NULL) { } 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))); 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"); fprintf(stderr, "Printing the command line for an action is not supported\n");
} else { } else {
set_dri_prime(info);
g_desktop_app_info_launch_action(info, action, NULL); g_desktop_app_info_launch_action(info, action, NULL);
utils_sleep_millis(500); utils_sleep_millis(500);
} }