diff options
author | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2015-12-15 14:05:42 +0100 |
---|---|---|
committer | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2015-12-15 15:02:13 +0100 |
commit | 6834a33290e7cf9466a3671cb00d3d7b08f68ca7 (patch) | |
tree | 45aa2beec058d40c2c8c08e14ad5c466e5027be2 | |
parent | Implement IPC_GET_BAR_CONFIG (diff) | |
download | sway-6834a33290e7cf9466a3671cb00d3d7b08f68ca7.tar.gz sway-6834a33290e7cf9466a3671cb00d3d7b08f68ca7.tar.zst sway-6834a33290e7cf9466a3671cb00d3d7b08f68ca7.zip |
Add bar height option (Airblader/i3)
-rw-r--r-- | include/config.h | 2 | ||||
-rw-r--r-- | sway/commands.c | 19 | ||||
-rw-r--r-- | sway/config.c | 2 | ||||
-rw-r--r-- | sway/ipc-server.c | 2 |
4 files changed, 22 insertions, 3 deletions
diff --git a/include/config.h b/include/config.h index 80340720..2f3b4cb0 100644 --- a/include/config.h +++ b/include/config.h | |||
@@ -92,7 +92,7 @@ struct bar_config { | |||
92 | list_t *bindings; | 92 | list_t *bindings; |
93 | char *status_command; | 93 | char *status_command; |
94 | char *font; | 94 | char *font; |
95 | int bar_height; | 95 | int height; // -1 not defined |
96 | int tray_padding; | 96 | int tray_padding; |
97 | bool workspace_buttons; | 97 | bool workspace_buttons; |
98 | bool strip_workspace_numbers; | 98 | bool strip_workspace_numbers; |
diff --git a/sway/commands.c b/sway/commands.c index 733fb293..23e6e68c 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -69,6 +69,7 @@ static sway_cmd bar_cmd_bindsym; | |||
69 | static sway_cmd bar_cmd_colors; | 69 | static sway_cmd bar_cmd_colors; |
70 | static sway_cmd bar_cmd_mode; | 70 | static sway_cmd bar_cmd_mode; |
71 | static sway_cmd bar_cmd_modifier; | 71 | static sway_cmd bar_cmd_modifier; |
72 | static sway_cmd bar_cmd_height; | ||
72 | static sway_cmd bar_cmd_hidden_state; | 73 | static sway_cmd bar_cmd_hidden_state; |
73 | static sway_cmd bar_cmd_id; | 74 | static sway_cmd bar_cmd_id; |
74 | static sway_cmd bar_cmd_position; | 75 | static sway_cmd bar_cmd_position; |
@@ -1592,6 +1593,23 @@ static struct cmd_results *bar_cmd_colors(int argc, char **argv) { | |||
1592 | return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL); | 1593 | return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL); |
1593 | } | 1594 | } |
1594 | 1595 | ||
1596 | static struct cmd_results *bar_cmd_height(int argc, char **argv) { | ||
1597 | struct cmd_results *error = NULL; | ||
1598 | if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) { | ||
1599 | return error; | ||
1600 | } | ||
1601 | |||
1602 | int height = atoi(argv[0]); | ||
1603 | if (height < 0) { | ||
1604 | return cmd_results_new(CMD_INVALID, "height", | ||
1605 | "Invalid height value: %s", argv[0]); | ||
1606 | } | ||
1607 | |||
1608 | config->current_bar->height = height; | ||
1609 | sway_log(L_DEBUG, "Setting bar height to %d on bar: %s", height, config->current_bar->id); | ||
1610 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
1611 | } | ||
1612 | |||
1595 | static struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { | 1613 | static struct cmd_results *bar_cmd_hidden_state(int argc, char **argv) { |
1596 | struct cmd_results *error = NULL; | 1614 | struct cmd_results *error = NULL; |
1597 | if ((error = checkarg(argc, "hidden_state", EXPECTED_EQUAL_TO, 1))) { | 1615 | if ((error = checkarg(argc, "hidden_state", EXPECTED_EQUAL_TO, 1))) { |
@@ -1831,6 +1849,7 @@ static struct cmd_handler bar_handlers[] = { | |||
1831 | { "bindsym", bar_cmd_bindsym }, | 1849 | { "bindsym", bar_cmd_bindsym }, |
1832 | { "colors", bar_cmd_colors }, | 1850 | { "colors", bar_cmd_colors }, |
1833 | { "font", NULL }, | 1851 | { "font", NULL }, |
1852 | { "height", bar_cmd_height }, | ||
1834 | { "hidden_state", bar_cmd_hidden_state }, | 1853 | { "hidden_state", bar_cmd_hidden_state }, |
1835 | { "id", bar_cmd_id }, | 1854 | { "id", bar_cmd_id }, |
1836 | { "mode", bar_cmd_mode }, | 1855 | { "mode", bar_cmd_mode }, |
diff --git a/sway/config.c b/sway/config.c index e0c9151d..ec875169 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -562,7 +562,7 @@ struct bar_config *default_bar_config(void) { | |||
562 | bar->bindings = create_list(); | 562 | bar->bindings = create_list(); |
563 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); | 563 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); |
564 | bar->font = strdup("monospace 10"); | 564 | bar->font = strdup("monospace 10"); |
565 | bar->bar_height = -1; | 565 | bar->height = -1; |
566 | bar->workspace_buttons = true; | 566 | bar->workspace_buttons = true; |
567 | bar->strip_workspace_numbers = false; | 567 | bar->strip_workspace_numbers = false; |
568 | bar->binding_mode_indicator = true; | 568 | bar->binding_mode_indicator = true; |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 727f06da..60b61d74 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -419,7 +419,7 @@ void ipc_client_handle_command(struct ipc_client *client) { | |||
419 | } | 419 | } |
420 | json_object_object_add(json, "status_command", json_object_new_string(bar->status_command)); | 420 | json_object_object_add(json, "status_command", json_object_new_string(bar->status_command)); |
421 | json_object_object_add(json, "font", json_object_new_string(bar->font)); | 421 | json_object_object_add(json, "font", json_object_new_string(bar->font)); |
422 | json_object_object_add(json, "bar_height", json_object_new_int(bar->bar_height)); | 422 | json_object_object_add(json, "bar_height", json_object_new_int(bar->height)); |
423 | json_object_object_add(json, "workspace_buttons", json_object_new_boolean(bar->workspace_buttons)); | 423 | json_object_object_add(json, "workspace_buttons", json_object_new_boolean(bar->workspace_buttons)); |
424 | json_object_object_add(json, "strip_workspace_numbers", json_object_new_boolean(bar->strip_workspace_numbers)); | 424 | json_object_object_add(json, "strip_workspace_numbers", json_object_new_boolean(bar->strip_workspace_numbers)); |
425 | json_object_object_add(json, "binding_mode_indicator", json_object_new_boolean(bar->binding_mode_indicator)); | 425 | json_object_object_add(json, "binding_mode_indicator", json_object_new_boolean(bar->binding_mode_indicator)); |