Skip to content

Commit

Permalink
Change dmenu output chooser to accept cmd string
Browse files Browse the repository at this point in the history
  • Loading branch information
columbarius committed Oct 15, 2020
1 parent 165e46a commit 09f978a
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ struct xdpw_wlr_output *wlr_output_chooser_simple(struct wl_list *output_list) {
return NULL;
}

static bool exec_chooser_dmenu(char *const argv[], char *buffer, unsigned long buffer_maxlength, char *name, unsigned long name_maxlength) {
static bool exec_chooser_dmenu(char *cmd, char *buffer, unsigned long buffer_maxlength, char *name, unsigned long name_maxlength) {
int p1[2]; //p -> c
int p2[2]; //c -> p

Expand Down Expand Up @@ -410,10 +410,10 @@ static bool exec_chooser_dmenu(char *const argv[], char *buffer, unsigned long b
close(p2[1]);

int err;
err = execvp(argv[0], argv);
err = execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL);
if (err == -1) {
perror("execvp");
logprint(WARN,"Failed to execute %s",argv[0]);
perror("execl");
logprint(WARN,"Failed to execute %s",cmd);
return false;
}
exit(127);
Expand Down Expand Up @@ -468,27 +468,15 @@ struct xdpw_wlr_output *wlr_output_chooser_dmenu(struct wl_list *output_list) {
}
buffer[maxlength - 1] = '\0';

char *argv_wofi[] = {
"wofi",
"-d",
"-n",
NULL,
};

char *argv_bemenu[] = {
char *cmds[] = {
"wofi -d -n",
"bemenu",
NULL,
};

void *argvs[] = {
argv_wofi,
argv_bemenu,
NULL
};

i = 0;
while (argvs[i] != NULL) {
if (exec_chooser_dmenu(argvs[i], buffer, maxlength, name, namelength)) {
while (cmds[i] != NULL) {
if (exec_chooser_dmenu(cmds[i], buffer, maxlength, name, namelength)) {
wl_list_for_each_safe(output, tmp, output_list, link) {
if (strcmp(output->name, name) == 0) {
return output;
Expand Down

0 comments on commit 09f978a

Please sign in to comment.