summaryrefslogtreecommitdiffstats
path: root/include
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 /include
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 'include')
-rw-r--r--include/bar/bar.h55
-rw-r--r--include/bar/config.h69
-rw-r--r--include/bar/ipc.h17
-rw-r--r--include/bar/render.h17
-rw-r--r--include/bar/status_line.h50
5 files changed, 208 insertions, 0 deletions
diff --git a/include/bar/bar.h b/include/bar/bar.h
new file mode 100644
index 00000000..89496da6
--- /dev/null
+++ b/include/bar/bar.h
@@ -0,0 +1,55 @@
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/include/bar/config.h b/include/bar/config.h
new file mode 100644
index 00000000..508b9c42
--- /dev/null
+++ b/include/bar/config.h
@@ -0,0 +1,69 @@
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/include/bar/ipc.h b/include/bar/ipc.h
new file mode 100644
index 00000000..c3f661f8
--- /dev/null
+++ b/include/bar/ipc.h
@@ -0,0 +1,17 @@
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/include/bar/render.h b/include/bar/render.h
new file mode 100644
index 00000000..931a1cdd
--- /dev/null
+++ b/include/bar/render.h
@@ -0,0 +1,17 @@
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/include/bar/status_line.h b/include/bar/status_line.h
new file mode 100644
index 00000000..273542dc
--- /dev/null
+++ b/include/bar/status_line.h
@@ -0,0 +1,50 @@
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 */