Added print_command to run

This commit is contained in:
Scoopta 2020-08-07 23:36:09 -07:00
parent 15d48b377d
commit 09efb27a78
2 changed files with 10 additions and 1 deletions

View File

@ -42,6 +42,9 @@ If true spaces will not be treated as part of the executable name but rather as
.TP .TP
.B show_all=\fIBOOL\fR .B show_all=\fIBOOL\fR
If true shows all the entries in path, this will show entries that have the same executable name, for example /bin/bash and /usr/bin/bash will be shown separately as bash instead of having one bash entry for the first one encountered, default is true. If true shows all the entries in path, this will show entries that have the same executable name, for example /bin/bash and /usr/bin/bash will be shown separately as bash instead of having one bash entry for the first one encountered, default is true.
.TP
.B print_command=\fIBOOL\fR
If true the executable that would be run will be printed to stdout instead of executing it, default is false.
.SH DRUN CONFIG OPTIONS .SH DRUN CONFIG OPTIONS
.TP .TP

View File

@ -28,10 +28,11 @@
#include <config.h> #include <config.h>
#include <wofi_api.h> #include <wofi_api.h>
static const char* arg_names[] = {"always_parse_args", "show_all"}; static const char* arg_names[] = {"always_parse_args", "show_all", "print_command"};
static bool always_parse_args; static bool always_parse_args;
static bool show_all; static bool show_all;
static bool print_command;
static struct mode* mode; static struct mode* mode;
static const char* arg_str = "__args"; static const char* arg_str = "__args";
@ -46,6 +47,7 @@ void wofi_run_init(struct mode* this, struct map* config) {
mode = this; mode = this;
always_parse_args = strcmp(config_get(config, arg_names[0], "false"), "true") == 0; always_parse_args = strcmp(config_get(config, arg_names[0], "false"), "true") == 0;
show_all = strcmp(config_get(config, arg_names[1], "true"), "true") == 0; show_all = strcmp(config_get(config, arg_names[1], "true"), "true") == 0;
print_command = strcmp(config_get(config, arg_names[2], "false"), "true") == 0;
wl_list_init(&widgets); wl_list_init(&widgets);
@ -188,6 +190,10 @@ void wofi_run_exec(const char* cmd) {
wofi_write_cache(mode, cmd); wofi_write_cache(mode, cmd);
wofi_term_run(cmd); wofi_term_run(cmd);
} }
if(print_command) {
printf("%s\n", cmd);
exit(0);
}
if(arg_run) { if(arg_run) {
size_t space_count = 2; size_t space_count = 2;
char* tmp = parse_args(cmd, &space_count); char* tmp = parse_args(cmd, &space_count);