aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-12-16 07:47:00 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-12-16 07:47:00 -0500
commit01798a5ae2a8776f5de4b4ab6391bc72f9af014f (patch)
treef7f5423256e2e7ade009b3a325d2825137d86b79 /sway
parentMerge pull request #339 from mikkeloscar/free-bar-3 (diff)
parentImplement bar option: separator_symbol (diff)
downloadsway-01798a5ae2a8776f5de4b4ab6391bc72f9af014f.tar.gz
sway-01798a5ae2a8776f5de4b4ab6391bc72f9af014f.tar.zst
sway-01798a5ae2a8776f5de4b4ab6391bc72f9af014f.zip
Merge pull request #338 from mikkeloscar/bar-separator-symbol
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 2f89cd39..7222b7a2 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]);
@@ -567,6 +568,7 @@ struct bar_config *default_bar_config(void) {
567 bar->font = strdup("monospace 10"); 568 bar->font = strdup("monospace 10");
568 bar->height = -1; 569 bar->height = -1;
569 bar->workspace_buttons = true; 570 bar->workspace_buttons = true;
571 bar->separator_symbol = NULL;
570 bar->strip_workspace_numbers = false; 572 bar->strip_workspace_numbers = false;
571 bar->binding_mode_indicator = true; 573 bar->binding_mode_indicator = true;
572 bar->tray_padding = 2; 574 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));