Added the config option drun-disable_prime to disable prime GPU offloading

This commit is contained in:
Scoopta 2022-12-25 15:54:50 -08:00
parent 4dd03d040e
commit 9aa93ed272
2 changed files with 7 additions and 2 deletions

View File

@ -53,6 +53,9 @@ If true the command used to launch the desktop file will be printed to stdout in
.TP .TP
.B display_generic=\fIBOOL\fR .B display_generic=\fIBOOL\fR
If true then generic names will be displayed in () next to the application name, default is false. If true then generic names will be displayed in () next to the application name, default is false.
.TP
.B disable_prime=\fIBOOL\fR
If true then wofi will ignore the PrefersNonDefaultGPU desktop variable, specifically this prevents wofi from setting DRI_PRIME, default is false.
.SH DRUN .SH DRUN
When images are enabled drun mode will pull icon themes however being a GTK app it's possible you'll need to run gtk\-update\-icon\-cache to get them to apply. When images are enabled drun mode will pull icon themes however being a GTK app it's possible you'll need to run gtk\-update\-icon\-cache to get them to apply.

View File

@ -29,7 +29,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gio/gdesktopappinfo.h> #include <gio/gdesktopappinfo.h>
static const char* arg_names[] = {"print_command", "display_generic"}; static const char* arg_names[] = {"print_command", "display_generic", "disable_prime"};
static struct mode* mode; static struct mode* mode;
@ -43,6 +43,7 @@ static struct wl_list desktop_entries;
static bool print_command; static bool print_command;
static bool display_generic; static bool display_generic;
static bool disable_prime;
static char* get_search_text(char* file) { static char* get_search_text(char* file) {
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file); GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file);
@ -335,6 +336,7 @@ void wofi_drun_init(struct mode* this, struct map* config) {
print_command = strcmp(config_get(config, "print_command", "false"), "true") == 0; print_command = strcmp(config_get(config, "print_command", "false"), "true") == 0;
display_generic = strcmp(config_get(config, "display_generic", "false"), "true") == 0; display_generic = strcmp(config_get(config, "display_generic", "false"), "true") == 0;
disable_prime = strcmp(config_get(config, "disable_prime", "false"), "true") == 0;
entries = map_init(); entries = map_init();
struct wl_list* cache = wofi_read_cache(mode); struct wl_list* cache = wofi_read_cache(mode);
@ -407,7 +409,7 @@ static void launch_done(GObject* obj, GAsyncResult* result, gpointer data) {
static void set_dri_prime(GDesktopAppInfo* info) { static void set_dri_prime(GDesktopAppInfo* info) {
bool dri_prime = g_desktop_app_info_get_boolean(info, "PrefersNonDefaultGPU"); bool dri_prime = g_desktop_app_info_get_boolean(info, "PrefersNonDefaultGPU");
if(dri_prime) { if(dri_prime && !disable_prime) {
setenv("DRI_PRIME", "1", true); setenv("DRI_PRIME", "1", true);
} }
} }