2017-03-11 05:41:24 +01:00
|
|
|
#define _XOPEN_SOURCE 500
|
2016-01-23 02:47:44 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2016-09-01 14:18:37 +02:00
|
|
|
#include "swaybar/config.h"
|
2018-03-29 05:04:20 +02:00
|
|
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
2016-01-23 02:47:44 +01:00
|
|
|
|
|
|
|
uint32_t parse_position(const char *position) {
|
2018-03-29 05:04:20 +02:00
|
|
|
uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
|
|
|
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
|
|
|
uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
|
|
|
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM;
|
2016-01-23 02:47:44 +01:00
|
|
|
if (strcmp("top", position) == 0) {
|
2018-03-29 05:04:20 +02:00
|
|
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz;
|
2016-01-23 02:47:44 +01:00
|
|
|
} else if (strcmp("bottom", position) == 0) {
|
2018-03-29 05:04:20 +02:00
|
|
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
|
2016-01-23 02:47:44 +01:00
|
|
|
} else if (strcmp("left", position) == 0) {
|
2018-03-29 05:04:20 +02:00
|
|
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | vert;
|
2016-01-23 02:47:44 +01:00
|
|
|
} else if (strcmp("right", position) == 0) {
|
2018-03-29 05:04:20 +02:00
|
|
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | vert;
|
2016-01-23 02:47:44 +01:00
|
|
|
} else {
|
2018-03-29 05:04:20 +02:00
|
|
|
return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz;
|
2016-01-23 02:47:44 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
char *parse_font(const char *font) {
|
|
|
|
char *new_font = NULL;
|
|
|
|
if (strncmp("pango:", font, 6) == 0) {
|
2016-03-29 23:31:44 +02:00
|
|
|
font += 6;
|
2016-01-23 02:47:44 +01:00
|
|
|
}
|
|
|
|
|
2016-03-29 23:31:44 +02:00
|
|
|
new_font = strdup(font);
|
|
|
|
|
2016-01-23 02:47:44 +01:00
|
|
|
return new_font;
|
|
|
|
}
|
|
|
|
|
2018-03-29 05:04:20 +02:00
|
|
|
struct swaybar_config *init_config() {
|
|
|
|
struct swaybar_config *config = calloc(1, sizeof(struct swaybar_config));
|
2016-01-23 02:47:44 +01:00
|
|
|
config->status_command = NULL;
|
2016-10-20 15:43:38 +02:00
|
|
|
config->pango_markup = false;
|
2018-03-29 05:04:20 +02:00
|
|
|
config->position = parse_position("bottom");
|
2016-01-24 00:23:09 +01:00
|
|
|
config->font = strdup("monospace 10");
|
2016-01-23 02:47:44 +01:00
|
|
|
config->mode = NULL;
|
|
|
|
config->sep_symbol = NULL;
|
|
|
|
config->strip_workspace_numbers = false;
|
|
|
|
config->binding_mode_indicator = true;
|
2016-07-17 17:26:38 +02:00
|
|
|
config->wrap_scroll = false;
|
2016-01-23 02:47:44 +01:00
|
|
|
config->workspace_buttons = true;
|
2016-02-23 15:06:04 +01:00
|
|
|
config->all_outputs = false;
|
2016-02-22 17:27:17 +01:00
|
|
|
config->outputs = create_list();
|
2016-01-23 02:47:44 +01:00
|
|
|
|
2016-01-24 00:23:09 +01:00
|
|
|
/* height */
|
|
|
|
config->height = 0;
|
2016-01-23 02:47:44 +01:00
|
|
|
|
|
|
|
/* colors */
|
|
|
|
config->colors.background = 0x000000FF;
|
|
|
|
config->colors.statusline = 0xFFFFFFFF;
|
|
|
|
config->colors.separator = 0x666666FF;
|
|
|
|
|
|
|
|
config->colors.focused_workspace.border = 0x4C7899FF;
|
|
|
|
config->colors.focused_workspace.background = 0x285577FF;
|
|
|
|
config->colors.focused_workspace.text = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
config->colors.active_workspace.border = 0x333333FF;
|
|
|
|
config->colors.active_workspace.background = 0x5F676AFF;
|
|
|
|
config->colors.active_workspace.text = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
config->colors.inactive_workspace.border = 0x333333FF;
|
|
|
|
config->colors.inactive_workspace.background = 0x222222FF;
|
|
|
|
config->colors.inactive_workspace.text = 0x888888FF;
|
|
|
|
|
|
|
|
config->colors.urgent_workspace.border = 0x2F343AFF;
|
|
|
|
config->colors.urgent_workspace.background = 0x900000FF;
|
|
|
|
config->colors.urgent_workspace.text = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
config->colors.binding_mode.border = 0x2F343AFF;
|
|
|
|
config->colors.binding_mode.background = 0x900000FF;
|
|
|
|
config->colors.binding_mode.text = 0xFFFFFFFF;
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2018-03-29 05:04:20 +02:00
|
|
|
void free_config(struct swaybar_config *config) {
|
2016-01-23 02:47:44 +01:00
|
|
|
free(config->status_command);
|
|
|
|
free(config->font);
|
|
|
|
free(config->mode);
|
|
|
|
free(config->sep_symbol);
|
|
|
|
free(config);
|
|
|
|
}
|