aboutsummaryrefslogtreecommitdiff
path: root/swaybar/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'swaybar/state.c')
-rw-r--r--swaybar/state.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/swaybar/state.c b/swaybar/state.c
new file mode 100644
index 00000000..900842e0
--- /dev/null
+++ b/swaybar/state.c
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+
+#include "list.h"
+#include "config.h"
+#include "status_line.h"
+#include "state.h"
+
+struct swaybar_state *init_state() {
+ struct swaybar_state *state = calloc(1, sizeof(struct swaybar_state));
+ state->config = init_config();
+ state->status = init_status_line();
+ state->output = malloc(sizeof(struct output));
+ state->output->window = NULL;
+ state->output->registry = NULL;
+ state->output->workspaces = create_list();
+
+ return state;
+}
+
+void free_workspace(void *item) {
+ if (!item) {
+ return;
+ }
+ struct workspace *ws = (struct workspace *)item;
+ if (ws->name) {
+ free(ws->name);
+ }
+ free(ws);
+}