UtkarshVerma / dwmblocks-async

An efficient, lean, and asynchronous status feed generator for dwm.
GNU General Public License v2.0
224 stars 87 forks source link

[SUGGESTION] execute commands directly rather than through a shell #38

Closed ghost closed 1 year ago

ghost commented 1 year ago

We can execute the commands directly rather than through another shell to avoid unnecessary nesting of shells.

By replacing

#define BLOCK(cmd, interval, signal) \
    { "echo \"$(" cmd ")\"", interval, signal }

with

#define BLOCK(cmd, interval, signal) \
    { cmd, interval, signal }

and

execl("/bin/sh", "sh", "-c", blocks[i].command, (char*)NULL);

with

execlp(blocks[i].command, (char*)NULL);

we can execute each block without the need of an extra shell.

I apologise for not having sent a PR, I have been having issues with Github recently.

UtkarshVerma commented 1 year ago

Running the command in another shell is one unsatisfying workaround which I've had to live to with. It is discussed in more detail in #24. Therefore, I will be closing this in favour of that issue.