aboutsummaryrefslogtreecommitdiffstats
path: root/swaybar/config.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-04-12 20:19:54 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-04-12 20:19:54 -0400
commitcd1b32453a9296c18b28bff71607aeb22987b5cd (patch)
treec653c6d525b471914c01a9d7ae543f521b6138ed /swaybar/config.c
parentMerge pull request #1634 from aleksander/master (diff)
parentFix separator height calculation (diff)
downloadsway-cd1b32453a9296c18b28bff71607aeb22987b5cd.tar.gz
sway-cd1b32453a9296c18b28bff71607aeb22987b5cd.tar.zst
sway-cd1b32453a9296c18b28bff71607aeb22987b5cd.zip
Merge branch 'wlroots'
Diffstat (limited to 'swaybar/config.c')
-rw-r--r--swaybar/config.c53
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
8uint32_t parse_position(const char *position) { 7uint32_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
22char *parse_font(const char *font) { 25struct 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
33struct 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
91void free_config(struct config *config) { 72void 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);