diff options
Diffstat (limited to 'swaybar/config.c')
-rw-r--r-- | swaybar/config.c | 53 |
1 files changed, 17 insertions, 36 deletions
diff --git a/swaybar/config.c b/swaybar/config.c index 8fe552f2..9169ad27 100644 --- a/swaybar/config.c +++ b/swaybar/config.c | |||
@@ -1,40 +1,32 @@ | |||
1 | #define _XOPEN_SOURCE 500 | 1 | #define _XOPEN_SOURCE 500 |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include "wayland-desktop-shell-client-protocol.h" | ||
5 | #include "log.h" | ||
6 | #include "swaybar/config.h" | 4 | #include "swaybar/config.h" |
5 | #include "wlr-layer-shell-unstable-v1-client-protocol.h" | ||
7 | 6 | ||
8 | uint32_t parse_position(const char *position) { | 7 | uint32_t parse_position(const char *position) { |
8 | uint32_t horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | | ||
9 | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; | ||
10 | uint32_t vert = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | | ||
11 | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM; | ||
9 | if (strcmp("top", position) == 0) { | 12 | if (strcmp("top", position) == 0) { |
10 | return DESKTOP_SHELL_PANEL_POSITION_TOP; | 13 | return ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | horiz; |
11 | } else if (strcmp("bottom", position) == 0) { | 14 | } else if (strcmp("bottom", position) == 0) { |
12 | return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | 15 | return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz; |
13 | } else if (strcmp("left", position) == 0) { | 16 | } else if (strcmp("left", position) == 0) { |
14 | return DESKTOP_SHELL_PANEL_POSITION_LEFT; | 17 | return ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | vert; |
15 | } else if (strcmp("right", position) == 0) { | 18 | } else if (strcmp("right", position) == 0) { |
16 | return DESKTOP_SHELL_PANEL_POSITION_RIGHT; | 19 | return ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | vert; |
17 | } else { | 20 | } else { |
18 | return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | 21 | return ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | horiz; |
19 | } | 22 | } |
20 | } | 23 | } |
21 | 24 | ||
22 | char *parse_font(const char *font) { | 25 | struct swaybar_config *init_config() { |
23 | char *new_font = NULL; | 26 | struct swaybar_config *config = calloc(1, sizeof(struct swaybar_config)); |
24 | if (strncmp("pango:", font, 6) == 0) { | ||
25 | font += 6; | ||
26 | } | ||
27 | |||
28 | new_font = strdup(font); | ||
29 | |||
30 | return new_font; | ||
31 | } | ||
32 | |||
33 | struct config *init_config() { | ||
34 | struct config *config = calloc(1, sizeof(struct config)); | ||
35 | config->status_command = NULL; | 27 | config->status_command = NULL; |
36 | config->pango_markup = false; | 28 | config->pango_markup = false; |
37 | config->position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | 29 | config->position = parse_position("bottom"); |
38 | config->font = strdup("monospace 10"); | 30 | config->font = strdup("monospace 10"); |
39 | config->mode = NULL; | 31 | config->mode = NULL; |
40 | config->sep_symbol = NULL; | 32 | config->sep_symbol = NULL; |
@@ -42,27 +34,16 @@ struct config *init_config() { | |||
42 | config->binding_mode_indicator = true; | 34 | config->binding_mode_indicator = true; |
43 | config->wrap_scroll = false; | 35 | config->wrap_scroll = false; |
44 | config->workspace_buttons = true; | 36 | config->workspace_buttons = true; |
45 | config->all_outputs = false; | 37 | wl_list_init(&config->outputs); |
46 | config->outputs = create_list(); | ||
47 | 38 | ||
48 | /* height */ | 39 | /* height */ |
49 | config->height = 0; | 40 | config->height = 0; |
50 | 41 | ||
51 | #ifdef ENABLE_TRAY | ||
52 | config->tray_output = NULL; | ||
53 | config->icon_theme = NULL; | ||
54 | config->tray_padding = 2; | ||
55 | /** | ||
56 | * These constants are used by wayland and are defined in | ||
57 | * linux/input-event-codes.h | ||
58 | */ | ||
59 | config->activate_button = 0x110; /* BTN_LEFT */ | ||
60 | config->context_button = 0x111; /* BTN_RIGHT */ | ||
61 | #endif | ||
62 | |||
63 | /* colors */ | 42 | /* colors */ |
64 | config->colors.background = 0x000000FF; | 43 | config->colors.background = 0x000000FF; |
44 | config->colors.focused_background = 0x000000FF; | ||
65 | config->colors.statusline = 0xFFFFFFFF; | 45 | config->colors.statusline = 0xFFFFFFFF; |
46 | config->colors.focused_statusline = 0xFFFFFFFF; | ||
66 | config->colors.separator = 0x666666FF; | 47 | config->colors.separator = 0x666666FF; |
67 | 48 | ||
68 | config->colors.focused_workspace.border = 0x4C7899FF; | 49 | config->colors.focused_workspace.border = 0x4C7899FF; |
@@ -88,7 +69,7 @@ struct config *init_config() { | |||
88 | return config; | 69 | return config; |
89 | } | 70 | } |
90 | 71 | ||
91 | void free_config(struct config *config) { | 72 | void free_config(struct swaybar_config *config) { |
92 | free(config->status_command); | 73 | free(config->status_command); |
93 | free(config->font); | 74 | free(config->font); |
94 | free(config->mode); | 75 | free(config->mode); |