aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/config.h1
-rw-r--r--sway/commands.c22
-rw-r--r--sway/config.c5
-rw-r--r--sway/ipc-server.c2
4 files changed, 28 insertions, 2 deletions
diff --git a/include/config.h b/include/config.h
index c2b67aa6..655d0a9c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -167,6 +167,7 @@ struct sway_config {
uint32_t resizing_key;
enum swayc_layouts default_orientation;
enum swayc_layouts default_layout;
+ char *font;
// Flags
bool focus_follows_mouse;
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 },
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) {
list_free(config->output_configs);
list_free(config->active_bar_modifiers);
+ free(config->font);
free(config);
}
@@ -149,6 +150,8 @@ static void config_defaults(struct sway_config *config) {
config->resizing_key = M_RIGHT_CLICK;
config->default_layout = L_NONE;
config->default_orientation = L_NONE;
+ config->font = strdup("pango:monospace 10");
+
// Flags
config->focus_follows_mouse = true;
config->mouse_warping = true;
@@ -879,7 +882,7 @@ struct bar_config *default_bar_config(void) {
bar->bindings = create_list();
bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p' && sleep 1; done");
bar->swaybar_command = NULL;
- bar->font = strdup("pango:monospace 10");
+ bar->font = NULL;
bar->height = -1;
bar->workspace_buttons = true;
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) {
break;
}
json_object_object_add(json, "status_command", json_object_new_string(bar->status_command));
- json_object_object_add(json, "font", json_object_new_string(bar->font));
+ json_object_object_add(json, "font", json_object_new_string(bar->font ? bar->font : config->font));
if (bar->separator_symbol) {
json_object_object_add(json, "separator_symbol", json_object_new_string(bar->separator_symbol));
}