aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-12-18 19:17:56 -0500
committerDrew DeVault <sir@cmpwn.com>2015-12-18 19:17:56 -0500
commit253efad43758a10ce26a767d4ad42cc5c32f8d0d (patch)
treea7973dad4c4871f93708c503cdefa03f0695f425
parent7647762bab3b625bba6004de761454a2ae4edc5d (diff)
parent207678e809eb4655ed725f904e25fb0df862dd6f (diff)
downloadsway-253efad43758a10ce26a767d4ad42cc5c32f8d0d.tar.xz
Merge pull request #361 from mikkeloscar/i3bar-command
Add support for running swaybar_command
-rw-r--r--sway/config.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/sway/config.c b/sway/config.c
index b0871366..faa3e387 100644
--- 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