aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
authorcrondog <crondog@gmail.com>2016-01-27 16:57:55 +1100
committercrondog <crondog@gmail.com>2016-01-27 20:53:31 +1100
commit0ee55474067364159f84806b7b0813492ed4e546 (patch)
treed1f5bd624cf3dccc1987ccfc1fe20130a2d4cf4a /sway/commands.c
parentbaa958eaf2a727c1f8e72aa2606b4b975087939f (diff)
font: Allow adding font to the config. In prep for border titles
v2: Give default font and make bar use it if no bar font
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c22
1 files changed, 22 insertions, 0 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;
static sway_cmd cmd_floating_mod;
static sway_cmd cmd_focus;
static sway_cmd cmd_focus_follows_mouse;
+static sway_cmd cmd_font;
static sway_cmd cmd_for_window;
static sway_cmd cmd_fullscreen;
static sway_cmd cmd_gaps;
@@ -1822,6 +1823,26 @@ static struct cmd_results *cmd_log_colors(int argc, char **argv) {
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
+static struct cmd_results *cmd_font(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "font", EXPECTED_AT_LEAST, 1))) {
+ return error;
+ }
+
+ char *font = join_args(argv, argc);
+ if (strlen(font) > 6 && strncmp("pango:", font, 6) == 0) {
+ free(config->font);
+ config->font = font;
+ sway_log(L_DEBUG, "Settings font %s", config->font);
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+ } else {
+ free(font);
+ return cmd_results_new(CMD_FAILURE, "font", "non-pango font detected");
+ }
+
+}
+
+
static struct cmd_results *cmd_for_window(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "for_window", EXPECTED_AT_LEAST, 2))) {
@@ -1978,6 +1999,7 @@ static struct cmd_handler handlers[] = {
{ "floating_modifier", cmd_floating_mod },
{ "focus", cmd_focus },
{ "focus_follows_mouse", cmd_focus_follows_mouse },
+ { "font", cmd_font },
{ "for_window", cmd_for_window },
{ "fullscreen", cmd_fullscreen },
{ "gaps", cmd_gaps },