aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-12-16 12:58:45 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2015-12-16 13:01:11 +0100
commit2fd7dd64ec8449f3a0e2ce9d445273b6f78a9dea (patch)
tree587a3da93a034f194355cba7b68ae7acd87ed9f4 /sway
parentApply color config from swaybar (diff)
downloadsway-2fd7dd64ec8449f3a0e2ce9d445273b6f78a9dea.tar.gz
sway-2fd7dd64ec8449f3a0e2ce9d445273b6f78a9dea.tar.zst
sway-2fd7dd64ec8449f3a0e2ce9d445273b6f78a9dea.zip
Implement bar option: separator_symbol
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c20
-rw-r--r--sway/config.c2
-rw-r--r--sway/ipc-server.c3
3 files changed, 24 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c
index f90a5ae9..4e9630ef 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -76,6 +76,7 @@ static sway_cmd bar_cmd_height;
76static sway_cmd bar_cmd_hidden_state; 76static sway_cmd bar_cmd_hidden_state;
77static sway_cmd bar_cmd_id; 77static sway_cmd bar_cmd_id;
78static sway_cmd bar_cmd_position; 78static sway_cmd bar_cmd_position;
79static sway_cmd bar_cmd_separator_symbol;
79static sway_cmd bar_cmd_status_command; 80static sway_cmd bar_cmd_status_command;
80static sway_cmd bar_cmd_strip_workspace_numbers; 81static sway_cmd bar_cmd_strip_workspace_numbers;
81static sway_cmd bar_cmd_tray_output; 82static sway_cmd bar_cmd_tray_output;
@@ -1840,6 +1841,23 @@ static struct cmd_results *bar_cmd_position(int argc, char **argv) {
1840 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 1841 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
1841} 1842}
1842 1843
1844static struct cmd_results *bar_cmd_separator_symbol(int argc, char **argv) {
1845 struct cmd_results *error = NULL;
1846 if ((error = checkarg(argc, "separator_symbol", EXPECTED_EQUAL_TO, 1))) {
1847 return error;
1848 }
1849
1850 if (!config->current_bar) {
1851 return cmd_results_new(CMD_FAILURE, "separator_symbol", "No bar defined.");
1852 }
1853
1854 free(config->current_bar->separator_symbol);
1855 config->current_bar->separator_symbol = strdup(argv[0]);
1856 sway_log(L_DEBUG, "Settings separator_symbol '%s' for bar: %s", config->current_bar->separator_symbol, config->current_bar->id);
1857
1858 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
1859}
1860
1843static struct cmd_results *bar_cmd_status_command(int argc, char **argv) { 1861static struct cmd_results *bar_cmd_status_command(int argc, char **argv) {
1844 struct cmd_results *error = NULL; 1862 struct cmd_results *error = NULL;
1845 if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) { 1863 if ((error = checkarg(argc, "status_command", EXPECTED_AT_LEAST, 1))) {
@@ -1945,7 +1963,7 @@ static struct cmd_handler bar_handlers[] = {
1945 { "modifier", bar_cmd_modifier }, 1963 { "modifier", bar_cmd_modifier },
1946 { "output", bar_cmd_output }, 1964 { "output", bar_cmd_output },
1947 { "position", bar_cmd_position }, 1965 { "position", bar_cmd_position },
1948 { "seperator_symbol", NULL }, 1966 { "separator_symbol", bar_cmd_separator_symbol },
1949 { "status_command", bar_cmd_status_command }, 1967 { "status_command", bar_cmd_status_command },
1950 { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers }, 1968 { "strip_workspace_numbers", bar_cmd_strip_workspace_numbers },
1951 { "tray_output", bar_cmd_tray_output }, 1969 { "tray_output", bar_cmd_tray_output },
diff --git a/sway/config.c b/sway/config.c
index e86bdab5..1473d130 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -43,6 +43,7 @@ static void free_bar(struct bar_config *bar) {
43 free(bar->hidden_state); 43 free(bar->hidden_state);
44 free(bar->status_command); 44 free(bar->status_command);
45 free(bar->font); 45 free(bar->font);
46 free(bar->separator_symbol);
46 int i; 47 int i;
47 for (i = 0; i < bar->bindings->length; ++i) { 48 for (i = 0; i < bar->bindings->length; ++i) {
48 free_sway_mouse_binding(bar->bindings->items[i]); 49 free_sway_mouse_binding(bar->bindings->items[i]);
@@ -570,6 +571,7 @@ struct bar_config *default_bar_config(void) {
570 bar->font = strdup("monospace 10"); 571 bar->font = strdup("monospace 10");
571 bar->height = -1; 572 bar->height = -1;
572 bar->workspace_buttons = true; 573 bar->workspace_buttons = true;
574 bar->separator_symbol = NULL;
573 bar->strip_workspace_numbers = false; 575 bar->strip_workspace_numbers = false;
574 bar->binding_mode_indicator = true; 576 bar->binding_mode_indicator = true;
575 bar->tray_padding = 2; 577 bar->tray_padding = 2;
diff --git a/sway/ipc-server.c b/sway/ipc-server.c
index ea8e8894..9dd3e1a5 100644
--- a/sway/ipc-server.c
+++ b/sway/ipc-server.c
@@ -419,6 +419,9 @@ 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 if (bar->separator_symbol) {
423 json_object_object_add(json, "separator_symbol", json_object_new_string(bar->separator_symbol));
424 }
422 json_object_object_add(json, "bar_height", json_object_new_int(bar->height)); 425 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)); 426 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)); 427 json_object_object_add(json, "strip_workspace_numbers", json_object_new_boolean(bar->strip_workspace_numbers));