diff options
-rw-r--r-- | config.in | 5 | ||||
-rw-r--r-- | sway/commands/bar.c | 14 | ||||
-rw-r--r-- | sway/commands/bar/status_command.c | 16 | ||||
-rw-r--r-- | sway/config/bar.c | 4 | ||||
-rw-r--r-- | sway/ipc-json.c | 4 | ||||
-rw-r--r-- | sway/sway-bar.5.scd | 3 | ||||
-rw-r--r-- | swaybar/bar.c | 2 |
7 files changed, 31 insertions, 17 deletions
@@ -202,6 +202,11 @@ bindsym $mod+r mode "resize" | |||
202 | # Read `man 5 sway-bar` for more information about this section. | 202 | # Read `man 5 sway-bar` for more information about this section. |
203 | bar { | 203 | bar { |
204 | position top | 204 | position top |
205 | |||
206 | # When the status_command prints a new line to stdout, swaybar updates. | ||
207 | # The default just shows the current date and time. | ||
208 | status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done | ||
209 | |||
205 | colors { | 210 | colors { |
206 | statusline #ffffff | 211 | statusline #ffffff |
207 | background #323232 | 212 | background #323232 |
diff --git a/sway/commands/bar.c b/sway/commands/bar.c index f760888e..03f4c557 100644 --- a/sway/commands/bar.c +++ b/sway/commands/bar.c | |||
@@ -46,14 +46,14 @@ struct cmd_results *cmd_bar(int argc, char **argv) { | |||
46 | return error; | 46 | return error; |
47 | } | 47 | } |
48 | 48 | ||
49 | if (!config->reading) { | 49 | if (find_handler(argv[0], bar_config_handlers, |
50 | if (!find_handler(argv[0], bar_config_handlers, | 50 | sizeof(bar_config_handlers))) { |
51 | sizeof(bar_config_handlers))) { | 51 | if (config->reading) { |
52 | return cmd_results_new(CMD_FAILURE, "bar", | 52 | return config_subcommand(argv, argc, bar_config_handlers, |
53 | "Can only be used in config file."); | 53 | sizeof(bar_config_handlers)); |
54 | } | 54 | } |
55 | return config_subcommand(argv, argc, bar_config_handlers, | 55 | return cmd_results_new(CMD_FAILURE, "bar", |
56 | sizeof(bar_config_handlers)); | 56 | "Can only be used in config file."); |
57 | } | 57 | } |
58 | 58 | ||
59 | if (argc > 1) { | 59 | if (argc > 1) { |
diff --git a/sway/commands/bar/status_command.c b/sway/commands/bar/status_command.c index 6f6f81a3..5ea22525 100644 --- a/sway/commands/bar/status_command.c +++ b/sway/commands/bar/status_command.c | |||
@@ -13,8 +13,18 @@ struct cmd_results *bar_cmd_status_command(int argc, char **argv) { | |||
13 | "status_command", "No bar defined."); | 13 | "status_command", "No bar defined."); |
14 | } | 14 | } |
15 | free(config->current_bar->status_command); | 15 | free(config->current_bar->status_command); |
16 | config->current_bar->status_command = join_args(argv, argc); | 16 | config->current_bar->status_command = NULL; |
17 | wlr_log(WLR_DEBUG, "Feeding bar with status command: %s", | 17 | |
18 | config->current_bar->status_command); | 18 | char *new_command = join_args(argv, argc); |
19 | if (strcmp(new_command, "-") != 0) { | ||
20 | config->current_bar->status_command = new_command; | ||
21 | wlr_log(WLR_DEBUG, "Feeding bar with status command: %s", | ||
22 | config->current_bar->status_command); | ||
23 | } | ||
24 | |||
25 | if (config->active && !config->validating) { | ||
26 | load_swaybars(); | ||
27 | } | ||
28 | |||
19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
20 | } | 30 | } |
diff --git a/sway/config/bar.c b/sway/config/bar.c index 48a632fb..b8695798 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c | |||
@@ -99,10 +99,6 @@ struct bar_config *default_bar_config(void) { | |||
99 | if (!(bar->bindings = create_list())) { | 99 | if (!(bar->bindings = create_list())) { |
100 | goto cleanup; | 100 | goto cleanup; |
101 | } | 101 | } |
102 | if (!(bar->status_command = | ||
103 | strdup("while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done"))) { | ||
104 | goto cleanup; | ||
105 | } | ||
106 | // set default colors | 102 | // set default colors |
107 | if (!(bar->colors.background = strndup("#000000ff", 9))) { | 103 | if (!(bar->colors.background = strndup("#000000ff", 9))) { |
108 | goto cleanup; | 104 | goto cleanup; |
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 7c5a0a5d..f02f370b 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -514,8 +514,8 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
514 | json_object_new_string(bar->hidden_state)); | 514 | json_object_new_string(bar->hidden_state)); |
515 | json_object_object_add(json, "position", | 515 | json_object_object_add(json, "position", |
516 | json_object_new_string(bar->position)); | 516 | json_object_new_string(bar->position)); |
517 | json_object_object_add(json, "status_command", | 517 | json_object_object_add(json, "status_command", bar->status_command ? |
518 | json_object_new_string(bar->status_command)); | 518 | json_object_new_string(bar->status_command) : NULL); |
519 | json_object_object_add(json, "font", | 519 | json_object_object_add(json, "font", |
520 | json_object_new_string((bar->font) ? bar->font : config->font)); | 520 | json_object_new_string((bar->font) ? bar->font : config->font)); |
521 | if (bar->separator_symbol) { | 521 | if (bar->separator_symbol) { |
diff --git a/sway/sway-bar.5.scd b/sway/sway-bar.5.scd index 00b9386e..8c7be8e7 100644 --- a/sway/sway-bar.5.scd +++ b/sway/sway-bar.5.scd | |||
@@ -17,6 +17,9 @@ Sway allows configuring swaybar in the sway configuration file. | |||
17 | 17 | ||
18 | https://i3wm.org/docs/i3bar-protocol.html | 18 | https://i3wm.org/docs/i3bar-protocol.html |
19 | 19 | ||
20 | If running this command via IPC, you can disable a running status command by | ||
21 | setting the command to a single dash: _swaybar bar bar-0 status\_command -_ | ||
22 | |||
20 | *pango\_markup* enabled|disabled | 23 | *pango\_markup* enabled|disabled |
21 | Enables or disables pango markup for status lines. This has no effect on | 24 | Enables or disables pango markup for status lines. This has no effect on |
22 | status lines using the i3bar JSON protocol. | 25 | status lines using the i3bar JSON protocol. |
diff --git a/swaybar/bar.c b/swaybar/bar.c index c86e71b8..3990f1ca 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -572,8 +572,8 @@ void bar_run(struct swaybar *bar) { | |||
572 | add_event(bar->status->read_fd, POLLIN, status_in, bar); | 572 | add_event(bar->status->read_fd, POLLIN, status_in, bar); |
573 | } | 573 | } |
574 | while (1) { | 574 | while (1) { |
575 | event_loop_poll(); | ||
576 | wl_display_flush(bar->display); | 575 | wl_display_flush(bar->display); |
576 | event_loop_poll(); | ||
577 | } | 577 | } |
578 | } | 578 | } |
579 | 579 | ||