Skip to content

Commit

Permalink
Change simple 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 e0ec840 commit b3d7ec6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/screencast/wlr_screencast.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ struct xdpw_wlr_output *xdpw_wlr_output_first(struct wl_list *output_list) {
return NULL;
}

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

Expand Down Expand Up @@ -323,11 +323,11 @@ static bool exec_chooser_simple(char *const argv[], char *name, unsigned long na
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]);
logprint(WARN,"Failed to execute %s",cmd);
return false;
}
exit(127);
Expand Down Expand Up @@ -363,20 +363,21 @@ struct xdpw_wlr_output *wlr_output_chooser_simple(struct wl_list *output_list) {
namelength++;

char name[namelength];
char *const argv[] = {
"slurp",
"-f",
"%o",
"-o",
NULL,
char *cmds[] = {
"slurp -f %o -o",
NULL
};

if (exec_chooser_simple(argv, name, namelength)) {
wl_list_for_each_safe(output, tmp, output_list, link) {
if (strcmp(output->name, name) == 0) {
return output;
i = 0;
while (cmds[i] != NULL) {
if (exec_chooser_simple(cmds[i], name, namelength)) {
wl_list_for_each_safe(output, tmp, output_list, link) {
if (strcmp(output->name, name) == 0) {
return output;
}
}
}
i++;
}
return NULL;
}
Expand Down

0 comments on commit b3d7ec6

Please sign in to comment.