mirror of
https://github.com/swaywm/sway.git
synced 2024-11-16 13:13:17 +00:00
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
This commit is contained in:
parent
baa958eaf2
commit
0ee5547406
|
@ -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;
|
||||
|
|
|
@ -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 },
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue