Added the drun-print_desktop_file option

This commit is contained in:
Scoopta 2024-01-19 13:50:37 -08:00
parent 3410f97499
commit 1f5161eb66
2 changed files with 12 additions and 1 deletions

View File

@ -56,6 +56,9 @@ If true then generic names will be displayed in () next to the application name,
.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.
.TP
.B print_desktop_file=\fIBOOL\fR
If true the path to the desktop file and the name of the corresponding action(if present) will be printed to stdout instead of invoking it, default is false.
.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.

View File

@ -29,7 +29,7 @@
#include <gtk/gtk.h>
#include <gio/gdesktopappinfo.h>
static const char* arg_names[] = {"print_command", "display_generic", "disable_prime"};
static const char* arg_names[] = {"print_command", "display_generic", "disable_prime", "print_desktop_file"};
static struct mode* mode;
@ -44,6 +44,7 @@ static struct wl_list desktop_entries;
static bool print_command;
static bool display_generic;
static bool disable_prime;
static bool print_desktop_file;
static char* get_search_text(char* file) {
GDesktopAppInfo* info = g_desktop_app_info_new_from_filename(file);
@ -338,6 +339,7 @@ void wofi_drun_init(struct mode* this, struct map* config) {
print_command = strcmp(config_get(config, "print_command", "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;
print_desktop_file = strcmp(config_get(config, "print_desktop_file", "false"), "true") == 0;
entries = map_init();
struct wl_list* cache = wofi_read_cache(mode);
@ -448,6 +450,9 @@ void wofi_drun_exec(const gchar* cmd) {
printf("%s\n", cmd);
free(cmd);
exit(0);
} else if(print_desktop_file) {
printf("%s\n", cmd);
exit(0);
} else {
set_dri_prime(info);
if(uses_dbus(info)) {
@ -468,6 +473,9 @@ void wofi_drun_exec(const gchar* cmd) {
printf("%s\n", cmd);
free(cmd);
fprintf(stderr, "Printing the command line for an action is not supported\n");
} else if(print_desktop_file) {
printf("%s %s\n", cmd, action);
exit(0);
} else {
set_dri_prime(info);
g_desktop_app_info_launch_action(info, action, NULL);