diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-15 18:11:21 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-15 18:11:21 -0500 |
commit | efff8e5ba5df6da4b64b61d3252743dba7124556 (patch) | |
tree | 25f4fcc8e4f889f4ea4b6bd45015a9d1e63d4b73 /sway | |
parent | c09af4c1655242674207fa6c29e1b953d43d0702 (diff) | |
parent | 93168517154cfc306008fbba7e13f2351f07860f (diff) |
Merge pull request #335 from mikkeloscar/bar-font
Implement bar option: font <font>
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 6eb383ba..f90a5ae9 100644 --- a/sway/commands.c +++ b/sway/commands.c @@ -68,6 +68,7 @@ static sway_cmd cmd_ws_auto_back_and_forth; static sway_cmd bar_cmd_binding_mode_indicator; static sway_cmd bar_cmd_bindsym; static sway_cmd bar_cmd_colors; +static sway_cmd bar_cmd_font; static sway_cmd bar_cmd_mode; static sway_cmd bar_cmd_modifier; static sway_cmd bar_cmd_output; @@ -1618,6 +1619,28 @@ static struct cmd_results *bar_cmd_colors(int argc, char **argv) { return cmd_results_new(CMD_BLOCK_BAR_COLORS, NULL, NULL); } +static struct cmd_results *bar_cmd_font(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) { + return error; + } + + if (!config->current_bar) { + return cmd_results_new(CMD_FAILURE, "font", "No bar defined."); + } + + char *font = join_args(argv, argc); + if (strlen(font) > 6 && strncmp("pango:", font, 6) == 0) { + free(config->current_bar->font); + config->current_bar->font = font; + sway_log(L_DEBUG, "Settings font '%s' for bar: %s", config->current_bar->font, config->current_bar->id); + } else { + sway_log(L_ERROR, "warning: non-pango font '%s' not supported.", font); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} + static struct cmd_results *bar_cmd_height(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "height", EXPECTED_EQUAL_TO, 1))) { @@ -1914,7 +1937,7 @@ static struct cmd_handler bar_handlers[] = { { "binding_mode_indicator", bar_cmd_binding_mode_indicator }, { "bindsym", bar_cmd_bindsym }, { "colors", bar_cmd_colors }, - { "font", NULL }, + { "font", bar_cmd_font }, { "height", bar_cmd_height }, { "hidden_state", bar_cmd_hidden_state }, { "id", bar_cmd_id }, |