summaryrefslogtreecommitdiffstats
path: root/swaybar
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-24 15:55:58 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-24 15:55:58 +0100
commited227f5664196d85194d63d01a5382499867a386 (patch)
tree0474bff44ae5880fd3336a0a9dd04641793f153e /swaybar
parentMerge pull request #467 from mikkeloscar/swaybar-refactor (diff)
downloadsway-ed227f5664196d85194d63d01a5382499867a386.tar.gz
sway-ed227f5664196d85194d63d01a5382499867a386.tar.zst
sway-ed227f5664196d85194d63d01a5382499867a386.zip
swaybar: move headers to include/bar
Diffstat (limited to 'swaybar')
-rw-r--r--swaybar/bar.c10
-rw-r--r--swaybar/bar.h55
-rw-r--r--swaybar/config.c2
-rw-r--r--swaybar/config.h69
-rw-r--r--swaybar/ipc.c4
-rw-r--r--swaybar/ipc.h17
-rw-r--r--swaybar/main.c2
-rw-r--r--swaybar/render.c6
-rw-r--r--swaybar/render.h17
-rw-r--r--swaybar/status_line.c4
-rw-r--r--swaybar/status_line.h50
11 files changed, 14 insertions, 222 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c
index fc01863b..d80c9af3 100644
--- a/swaybar/bar.c
+++ b/swaybar/bar.c
@@ -8,11 +8,11 @@
8#include "ipc-client.h" 8#include "ipc-client.h"
9#include "list.h" 9#include "list.h"
10#include "log.h" 10#include "log.h"
11#include "ipc.h" 11#include "bar/ipc.h"
12#include "render.h" 12#include "bar/render.h"
13#include "config.h" 13#include "bar/config.h"
14#include "status_line.h" 14#include "bar/status_line.h"
15#include "bar.h" 15#include "bar/bar.h"
16 16
17static void bar_init(struct bar *bar) { 17static void bar_init(struct bar *bar) {
18 bar->config = init_config(); 18 bar->config = init_config();
diff --git a/swaybar/bar.h b/swaybar/bar.h
deleted file mode 100644
index 89496da6..00000000
--- a/swaybar/bar.h
+++ /dev/null
@@ -1,55 +0,0 @@
1#ifndef _SWAYBAR_BAR_H
2#define _SWAYBAR_BAR_H
3
4#include "client/registry.h"
5#include "client/window.h"
6#include "list.h"
7
8struct bar {
9 struct config *config;
10 struct status_line *status;
11 struct output *output;
12 /* list_t *outputs; */
13
14 int ipc_event_socketfd;
15 int ipc_socketfd;
16 int status_read_fd;
17 pid_t status_command_pid;
18};
19
20struct output {
21 struct window *window;
22 struct registry *registry;
23 list_t *workspaces;
24 char *name;
25};
26
27struct workspace {
28 int num;
29 char *name;
30 bool focused;
31 bool visible;
32 bool urgent;
33};
34
35/**
36 * Setup bar.
37 */
38void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id, int desired_output);
39
40/**
41 * Bar mainloop.
42 */
43void bar_run(struct bar *bar);
44
45/**
46 * free workspace list.
47 */
48void free_workspaces(list_t *workspaces);
49
50/**
51 * Teardown bar.
52 */
53void bar_teardown(struct bar *bar);
54
55#endif /* _SWAYBAR_BAR_H */
diff --git a/swaybar/config.c b/swaybar/config.c
index 28b609e6..92251831 100644
--- a/swaybar/config.c
+++ b/swaybar/config.c
@@ -3,7 +3,7 @@
3 3
4#include "wayland-desktop-shell-client-protocol.h" 4#include "wayland-desktop-shell-client-protocol.h"
5#include "log.h" 5#include "log.h"
6#include "config.h" 6#include "bar/config.h"
7 7
8uint32_t parse_color(const char *color) { 8uint32_t parse_color(const char *color) {
9 if (color[0] != '#') { 9 if (color[0] != '#') {
diff --git a/swaybar/config.h b/swaybar/config.h
deleted file mode 100644
index 508b9c42..00000000
--- a/swaybar/config.h
+++ /dev/null
@@ -1,69 +0,0 @@
1#ifndef _SWAYBAR_CONFIG_H
2#define _SWAYBAR_CONFIG_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
7/**
8 * Colors for a box with background, border and text colors.
9 */
10struct box_colors {
11 uint32_t border;
12 uint32_t background;
13 uint32_t text;
14};
15
16/**
17 * Swaybar config.
18 */
19struct config {
20 char *status_command;
21 uint32_t position;
22 char *font;
23 char *sep_symbol;
24 char *mode;
25 bool strip_workspace_numbers;
26 bool binding_mode_indicator;
27 bool workspace_buttons;
28
29 int height;
30
31 struct {
32 uint32_t background;
33 uint32_t statusline;
34 uint32_t separator;
35
36 struct box_colors focused_workspace;
37 struct box_colors active_workspace;
38 struct box_colors inactive_workspace;
39 struct box_colors urgent_workspace;
40 struct box_colors binding_mode;
41 } colors;
42};
43
44/**
45 * Parse colors defined as hex string to uint32_t.
46 */
47uint32_t parse_color(const char *color);
48
49/**
50 * Parse position top|bottom|left|right.
51 */
52uint32_t parse_position(const char *position);
53
54/**
55 * Parse font.
56 */
57char *parse_font(const char *font);
58
59/**
60 * Initialize default sway config.
61 */
62struct config *init_config();
63
64/**
65 * Free config struct.
66 */
67void free_config(struct config *config);
68
69#endif /* _SWAYBAR_CONFIG_H */
diff --git a/swaybar/ipc.c b/swaybar/ipc.c
index 547041ce..4104103d 100644
--- a/swaybar/ipc.c
+++ b/swaybar/ipc.c
@@ -4,8 +4,8 @@
4#include "ipc-client.h" 4#include "ipc-client.h"
5#include "list.h" 5#include "list.h"
6#include "log.h" 6#include "log.h"
7#include "config.h" 7#include "bar/config.h"
8#include "ipc.h" 8#include "bar/ipc.h"
9 9
10static void ipc_parse_config(struct config *config, const char *payload) { 10static void ipc_parse_config(struct config *config, const char *payload) {
11 json_object *bar_config = json_tokener_parse(payload); 11 json_object *bar_config = json_tokener_parse(payload);
diff --git a/swaybar/ipc.h b/swaybar/ipc.h
deleted file mode 100644
index c3f661f8..00000000
--- a/swaybar/ipc.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef _SWAYBAR_IPC_H
2#define _SWAYBAR_IPC_H
3
4#include "bar.h"
5
6/**
7 * Initialize ipc connection to sway and get sway state, outputs, bar_config.
8 */
9void ipc_bar_init(struct bar *bar, int outputi, const char *bar_id);
10
11/**
12 * Handle ipc event from sway.
13 */
14bool handle_ipc_event(struct bar *bar);
15
16#endif /* _SWAYBAR_IPC_H */
17
diff --git a/swaybar/main.c b/swaybar/main.c
index fc5acdae..737ee647 100644
--- a/swaybar/main.c
+++ b/swaybar/main.c
@@ -5,7 +5,7 @@
5#include <getopt.h> 5#include <getopt.h>
6#include "ipc-client.h" 6#include "ipc-client.h"
7#include "log.h" 7#include "log.h"
8#include "bar.h" 8#include "bar/bar.h"
9 9
10/* global bar state */ 10/* global bar state */
11struct bar swaybar; 11struct bar swaybar;
diff --git a/swaybar/render.c b/swaybar/render.c
index f3ce6010..bac44075 100644
--- a/swaybar/render.c
+++ b/swaybar/render.c
@@ -4,9 +4,9 @@
4 4
5#include "client/pango.h" 5#include "client/pango.h"
6#include "client/window.h" 6#include "client/window.h"
7#include "config.h" 7#include "bar/config.h"
8#include "status_line.h" 8#include "bar/status_line.h"
9#include "render.h" 9#include "bar/render.h"
10 10
11 11
12/* internal spacing */ 12/* internal spacing */
diff --git a/swaybar/render.h b/swaybar/render.h
deleted file mode 100644
index 931a1cdd..00000000
--- a/swaybar/render.h
+++ /dev/null
@@ -1,17 +0,0 @@
1#ifndef _SWAYBAR_RENDER_H
2#define _SWAYBAR_RENDER_H
3
4#include "config.h"
5#include "bar.h"
6
7/**
8 * Render swaybar.
9 */
10void render(struct output *output, struct config *config, struct status_line *line);
11
12/**
13 * Set window height and modify internal spacing accordingly.
14 */
15void set_window_height(struct window *window, int height);
16
17#endif /* _SWAYBAR_RENDER_H */
diff --git a/swaybar/status_line.c b/swaybar/status_line.c
index 6b630c49..ba6de6a1 100644
--- a/swaybar/status_line.c
+++ b/swaybar/status_line.c
@@ -4,8 +4,8 @@
4#include <json-c/json.h> 4#include <json-c/json.h>
5 5
6#include "log.h" 6#include "log.h"
7#include "config.h" 7#include "bar/config.h"
8#include "status_line.h" 8#include "bar/status_line.h"
9 9
10#define I3JSON_MAXDEPTH 4 10#define I3JSON_MAXDEPTH 4
11#define I3JSON_UNKNOWN 0 11#define I3JSON_UNKNOWN 0
diff --git a/swaybar/status_line.h b/swaybar/status_line.h
deleted file mode 100644
index 273542dc..00000000
--- a/swaybar/status_line.h
+++ /dev/null
@@ -1,50 +0,0 @@
1#ifndef _SWAYBAR_STATUS_LINE_H
2#define _SWAYBAR_STATUS_LINE_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
7#include "list.h"
8#include "bar.h"
9
10typedef enum {UNDEF, TEXT, I3BAR} command_protocol;
11
12struct status_line {
13 list_t *block_line;
14 const char *text_line;
15 command_protocol protocol;
16};
17
18struct status_block {
19 char *full_text, *short_text, *align;
20 bool urgent;
21 uint32_t color;
22 int min_width;
23 char *name, *instance;
24 bool separator;
25 int separator_block_width;
26 // Airblader features
27 uint32_t background;
28 uint32_t border;
29 int border_top;
30 int border_bottom;
31 int border_left;
32 int border_right;
33};
34
35/**
36 * Initialize status line struct.
37 */
38struct status_line *init_status_line();
39
40/**
41 * handle status line activity.
42 */
43bool handle_status_line(struct bar *bar);
44
45/**
46 * Free status line struct.
47 */
48void free_status_line(struct status_line *line);
49
50#endif /* _SWAYBAR_STATUS_LINE_H */