sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit 207678e809eb4655ed725f904e25fb0df862dd6f
parent 2ab4e5676e1dc0ddd4323a1cce6a3060ccf4f8c0
Author: Mikkel Oscar Lyderik <mikkeloscar@gmail.com>
Date:   Sat, 19 Dec 2015 01:03:39 +0100

Add support for running swaybar_command

Diffstat:
Msway/config.c | 35++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)

diff --git a/sway/config.c b/sway/config.c @@ -371,18 +371,35 @@ static void invoke_swaybar(swayc_t *output, struct bar_config *bar, int output_i snprintf(output_id, bufsize, "%d", output_i); output_id[bufsize-1] = 0; - char *const cmd[] = { - "swaybar", - "-b", - bar->id, - output_id, - NULL, - }; - pid_t *pid = malloc(sizeof(pid_t)); *pid = fork(); if (*pid == 0) { - execvp(cmd[0], cmd); + if (!bar->swaybar_command) { + char *const cmd[] = { + "swaybar", + "-b", + bar->id, + output_id, + NULL, + }; + + execvp(cmd[0], cmd); + } else { + // run custom swaybar + int len = strlen(bar->swaybar_command) + strlen(bar->id) + strlen(output_id) + 6; + char *command = malloc(len * sizeof(char)); + snprintf(command, len, "%s -b %s %s", bar->swaybar_command, bar->id, output_id); + + char *const cmd[] = { + "sh", + "-c", + command, + NULL, + }; + + execvp(cmd[0], cmd); + free(command); + } } // add swaybar pid to output