diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 22 | ||||
-rw-r--r-- | sway/config.c | 5 | ||||
-rw-r--r-- | sway/ipc-server.c | 2 |
3 files changed, 27 insertions, 2 deletions
diff --git a/sway/commands.c b/sway/commands.c index ae5c48e6..8fec1223 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -51,6 +51,7 @@ static sway_cmd cmd_floating; | |||
51 | static sway_cmd cmd_floating_mod; | 51 | static sway_cmd cmd_floating_mod; |
52 | static sway_cmd cmd_focus; | 52 | static sway_cmd cmd_focus; |
53 | static sway_cmd cmd_focus_follows_mouse; | 53 | static sway_cmd cmd_focus_follows_mouse; |
54 | static sway_cmd cmd_font; | ||
54 | static sway_cmd cmd_for_window; | 55 | static sway_cmd cmd_for_window; |
55 | static sway_cmd cmd_fullscreen; | 56 | static sway_cmd cmd_fullscreen; |
56 | static sway_cmd cmd_gaps; | 57 | static sway_cmd cmd_gaps; |
@@ -1822,6 +1823,26 @@ static struct cmd_results *cmd_log_colors(int argc, char **argv) { | |||
1822 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 1823 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
1823 | } | 1824 | } |
1824 | 1825 | ||
1826 | static struct cmd_results *cmd_font(int argc, char **argv) { | ||
1827 | struct cmd_results *error = NULL; | ||
1828 | if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) { | ||
1829 | return error; | ||
1830 | } | ||
1831 | |||
1832 | char *font = join_args(argv, argc); | ||
1833 | if (strlen(font) > 6 && strncmp("pango:", font, 6) == 0) { | ||
1834 | free(config->font); | ||
1835 | config->font = font; | ||
1836 | sway_log(L_DEBUG, "Settings font %s", config->font); | ||
1837 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
1838 | } else { | ||
1839 | free(font); | ||
1840 | return cmd_results_new(CMD_FAILURE, "font", "non-pango font detected"); | ||
1841 | } | ||
1842 | |||
1843 | } | ||
1844 | |||
1845 | |||
1825 | static struct cmd_results *cmd_for_window(int argc, char **argv) { | 1846 | static struct cmd_results *cmd_for_window(int argc, char **argv) { |
1826 | struct cmd_results *error = NULL; | 1847 | struct cmd_results *error = NULL; |
1827 | if ((error = checkarg(argc, "for_window", EXPECTED_AT_LEAST, 2))) { | 1848 | if ((error = checkarg(argc, "for_window", EXPECTED_AT_LEAST, 2))) { |
@@ -1978,6 +1999,7 @@ static struct cmd_handler handlers[] = { | |||
1978 | { "floating_modifier", cmd_floating_mod }, | 1999 | { "floating_modifier", cmd_floating_mod }, |
1979 | { "focus", cmd_focus }, | 2000 | { "focus", cmd_focus }, |
1980 | { "focus_follows_mouse", cmd_focus_follows_mouse }, | 2001 | { "focus_follows_mouse", cmd_focus_follows_mouse }, |
2002 | { "font", cmd_font }, | ||
1981 | { "for_window", cmd_for_window }, | 2003 | { "for_window", cmd_for_window }, |
1982 | { "fullscreen", cmd_fullscreen }, | 2004 | { "fullscreen", cmd_fullscreen }, |
1983 | { "gaps", cmd_gaps }, | 2005 | { "gaps", cmd_gaps }, |
diff --git a/sway/config.c b/sway/config.c index c4614521..65dba365 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -119,6 +119,7 @@ static void free_config(struct sway_config *config) { | |||
119 | list_free(config->output_configs); | 119 | list_free(config->output_configs); |
120 | 120 | ||
121 | list_free(config->active_bar_modifiers); | 121 | list_free(config->active_bar_modifiers); |
122 | free(config->font); | ||
122 | free(config); | 123 | free(config); |
123 | } | 124 | } |
124 | 125 | ||
@@ -149,6 +150,8 @@ static void config_defaults(struct sway_config *config) { | |||
149 | config->resizing_key = M_RIGHT_CLICK; | 150 | config->resizing_key = M_RIGHT_CLICK; |
150 | config->default_layout = L_NONE; | 151 | config->default_layout = L_NONE; |
151 | config->default_orientation = L_NONE; | 152 | config->default_orientation = L_NONE; |
153 | config->font = strdup("pango:monospace 10"); | ||
154 | |||
152 | // Flags | 155 | // Flags |
153 | config->focus_follows_mouse = true; | 156 | config->focus_follows_mouse = true; |
154 | config->mouse_warping = true; | 157 | config->mouse_warping = true; |
@@ -879,7 +882,7 @@ struct bar_config *default_bar_config(void) { | |||
879 | bar->bindings = create_list(); | 882 | bar->bindings = create_list(); |
880 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); | 883 | bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done"); |
881 | bar->swaybar_command = NULL; | 884 | bar->swaybar_command = NULL; |
882 | bar->font = strdup("pango:monospace 10"); | 885 | bar->font = NULL; |
883 | bar->height = -1; | 886 | bar->height = -1; |
884 | bar->workspace_buttons = true; | 887 | bar->workspace_buttons = true; |
885 | bar->separator_symbol = NULL; | 888 | bar->separator_symbol = NULL; |
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 58a291cd..63a6d703 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -551,7 +551,7 @@ json_object *ipc_json_describe_bar_config(struct bar_config *bar) { | |||
551 | break; | 551 | break; |
552 | } | 552 | } |
553 | json_object_object_add(json, "status_command", json_object_new_string(bar->status_command)); | 553 | json_object_object_add(json, "status_command", json_object_new_string(bar->status_command)); |
554 | json_object_object_add(json, "font", json_object_new_string(bar->font)); | 554 | json_object_object_add(json, "font", json_object_new_string(bar->font ? bar->font : config->font)); |
555 | if (bar->separator_symbol) { | 555 | if (bar->separator_symbol) { |
556 | json_object_object_add(json, "separator_symbol", json_object_new_string(bar->separator_symbol)); | 556 | json_object_object_add(json, "separator_symbol", json_object_new_string(bar->separator_symbol)); |
557 | } | 557 | } |