aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 17:41:02 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2018-03-29 22:11:08 -0400
commit569b2bfd5daae5b3be49772bdca4a3f224e20629 (patch)
tree56e1d9e37cc5ffdca34d2f86a0e297cd06ffaf83 /sway/config
parentAdd bar configuration commands (diff)
downloadsway-569b2bfd5daae5b3be49772bdca4a3f224e20629.tar.gz
sway-569b2bfd5daae5b3be49772bdca4a3f224e20629.tar.zst
sway-569b2bfd5daae5b3be49772bdca4a3f224e20629.zip
Move bar config into its own file
Diffstat (limited to 'sway/config')
-rw-r--r--sway/config/bar.c143
-rw-r--r--sway/config/output.c2
2 files changed, 144 insertions, 1 deletions
diff --git a/sway/config/bar.c b/sway/config/bar.c
new file mode 100644
index 00000000..ecc357d0
--- /dev/null
+++ b/sway/config/bar.c
@@ -0,0 +1,143 @@
1#define _POSIX_C_SOURCE 200809L
2#define _XOPEN_SOURCE 700
3#include <stdio.h>
4#include <stdbool.h>
5#include <stdlib.h>
6#include <unistd.h>
7#include <wordexp.h>
8#include <sys/types.h>
9#include <sys/wait.h>
10#include <sys/stat.h>
11#include <signal.h>
12#include <strings.h>
13#include "sway/config.h"
14#include "stringop.h"
15#include "list.h"
16#include "log.h"
17
18void free_bar_config(struct bar_config *bar) {
19 if (!bar) {
20 return;
21 }
22 free(bar->mode);
23 free(bar->position);
24 free(bar->hidden_state);
25 free(bar->status_command);
26 free(bar->font);
27 free(bar->separator_symbol);
28 // TODO: Free mouse bindings
29 list_free(bar->bindings);
30 if (bar->outputs) {
31 free_flat_list(bar->outputs);
32 }
33 if (bar->pid != 0) {
34 // TODO terminate_swaybar(bar->pid);
35 }
36 free(bar->colors.background);
37 free(bar->colors.statusline);
38 free(bar->colors.separator);
39 free(bar->colors.focused_background);
40 free(bar->colors.focused_statusline);
41 free(bar->colors.focused_separator);
42 free(bar->colors.focused_workspace_border);
43 free(bar->colors.focused_workspace_bg);
44 free(bar->colors.focused_workspace_text);
45 free(bar->colors.active_workspace_border);
46 free(bar->colors.active_workspace_bg);
47 free(bar->colors.active_workspace_text);
48 free(bar->colors.inactive_workspace_border);
49 free(bar->colors.inactive_workspace_bg);
50 free(bar->colors.inactive_workspace_text);
51 free(bar->colors.urgent_workspace_border);
52 free(bar->colors.urgent_workspace_bg);
53 free(bar->colors.urgent_workspace_text);
54 free(bar->colors.binding_mode_border);
55 free(bar->colors.binding_mode_bg);
56 free(bar->colors.binding_mode_text);
57 free(bar);
58}
59
60struct bar_config *default_bar_config(void) {
61 struct bar_config *bar = NULL;
62 bar = malloc(sizeof(struct bar_config));
63 if (!bar) {
64 return NULL;
65 }
66 if (!(bar->mode = strdup("dock"))) goto cleanup;
67 if (!(bar->hidden_state = strdup("hide"))) goto cleanup;
68 bar->outputs = NULL;
69 bar->position = strdup("bottom");
70 if (!(bar->bindings = create_list())) goto cleanup;
71 if (!(bar->status_command = strdup("while :; do date +'%Y-%m-%d %l:%M:%S %p'; sleep 1; done"))) goto cleanup;
72 bar->pango_markup = false;
73 bar->swaybar_command = NULL;
74 bar->font = NULL;
75 bar->height = -1;
76 bar->workspace_buttons = true;
77 bar->wrap_scroll = false;
78 bar->separator_symbol = NULL;
79 bar->strip_workspace_numbers = false;
80 bar->binding_mode_indicator = true;
81 bar->verbose = false;
82 bar->pid = 0;
83 // set default colors
84 if (!(bar->colors.background = strndup("#000000ff", 9))) {
85 goto cleanup;
86 }
87 if (!(bar->colors.statusline = strndup("#ffffffff", 9))) {
88 goto cleanup;
89 }
90 if (!(bar->colors.separator = strndup("#666666ff", 9))) {
91 goto cleanup;
92 }
93 if (!(bar->colors.focused_workspace_border = strndup("#4c7899ff", 9))) {
94 goto cleanup;
95 }
96 if (!(bar->colors.focused_workspace_bg = strndup("#285577ff", 9))) {
97 goto cleanup;
98 }
99 if (!(bar->colors.focused_workspace_text = strndup("#ffffffff", 9))) {
100 goto cleanup;
101 }
102 if (!(bar->colors.active_workspace_border = strndup("#333333ff", 9))) {
103 goto cleanup;
104 }
105 if (!(bar->colors.active_workspace_bg = strndup("#5f676aff", 9))) {
106 goto cleanup;
107 }
108 if (!(bar->colors.active_workspace_text = strndup("#ffffffff", 9))) {
109 goto cleanup;
110 }
111 if (!(bar->colors.inactive_workspace_border = strndup("#333333ff", 9))) {
112 goto cleanup;
113 }
114 if (!(bar->colors.inactive_workspace_bg = strndup("#222222ff", 9))) {
115 goto cleanup;
116 }
117 if (!(bar->colors.inactive_workspace_text = strndup("#888888ff", 9))) {
118 goto cleanup;
119 }
120 if (!(bar->colors.urgent_workspace_border = strndup("#2f343aff", 9))) {
121 goto cleanup;
122 }
123 if (!(bar->colors.urgent_workspace_bg = strndup("#900000ff", 9))) {
124 goto cleanup;
125 }
126 if (!(bar->colors.urgent_workspace_text = strndup("#ffffffff", 9))) {
127 goto cleanup;
128 }
129 // if the following colors stay undefined, they fall back to background,
130 // statusline, separator and urgent_workspace_*.
131 bar->colors.focused_background = NULL;
132 bar->colors.focused_statusline = NULL;
133 bar->colors.focused_separator = NULL;
134 bar->colors.binding_mode_border = NULL;
135 bar->colors.binding_mode_bg = NULL;
136 bar->colors.binding_mode_text = NULL;
137
138 list_add(config->bars, bar);
139 return bar;
140cleanup:
141 free_bar_config(bar);
142 return NULL;
143}
diff --git a/sway/config/output.c b/sway/config/output.c
index 9e211861..24b4a18e 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -186,7 +186,7 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
186 output_id[bufsize-1] = 0; 186 output_id[bufsize-1] = 0;
187 187
188 char *const cmd[] = { 188 char *const cmd[] = {
189 "./swaybg/swaybg", 189 "swaybg",
190 output_id, 190 output_id,
191 oc->background, 191 oc->background,
192 oc->background_option, 192 oc->background_option,