summaryrefslogtreecommitdiffstats
path: root/include/swaybar
diff options
context:
space:
mode:
Diffstat (limited to 'include/swaybar')
-rw-r--r--include/swaybar/bar.h63
-rw-r--r--include/swaybar/config.h71
-rw-r--r--include/swaybar/ipc.h23
-rw-r--r--include/swaybar/render.h22
-rw-r--r--include/swaybar/status_line.h51
5 files changed, 230 insertions, 0 deletions
diff --git a/include/swaybar/bar.h b/include/swaybar/bar.h
new file mode 100644
index 00000000..a3c511d9
--- /dev/null
+++ b/include/swaybar/bar.h
@@ -0,0 +1,63 @@
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 list_t *outputs;
12
13 int ipc_event_socketfd;
14 int ipc_socketfd;
15 int status_read_fd;
16 pid_t status_command_pid;
17};
18
19struct output {
20 struct window *window;
21 struct registry *registry;
22 list_t *workspaces;
23 char *name;
24 int idx;
25};
26
27struct workspace {
28 int num;
29 char *name;
30 bool focused;
31 bool visible;
32 bool urgent;
33};
34
35/** Global bar state */
36extern struct bar swaybar;
37
38/**
39 * Setup bar.
40 */
41void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id);
42
43/**
44 * Create new output struct from name.
45 */
46struct output *new_output(const char *name);
47
48/**
49 * Bar mainloop.
50 */
51void bar_run(struct bar *bar);
52
53/**
54 * free workspace list.
55 */
56void free_workspaces(list_t *workspaces);
57
58/**
59 * Teardown bar.
60 */
61void bar_teardown(struct bar *bar);
62
63#endif /* _SWAYBAR_BAR_H */
diff --git a/include/swaybar/config.h b/include/swaybar/config.h
new file mode 100644
index 00000000..934116ca
--- /dev/null
+++ b/include/swaybar/config.h
@@ -0,0 +1,71 @@
1#ifndef _SWAYBAR_CONFIG_H
2#define _SWAYBAR_CONFIG_H
3
4#include <stdint.h>
5#include <stdbool.h>
6
7#include "list.h"
8#include "util.h"
9
10/**
11 * Colors for a box with background, border and text colors.
12 */
13struct box_colors {
14 uint32_t border;
15 uint32_t background;
16 uint32_t text;
17};
18
19/**
20 * Swaybar config.
21 */
22struct config {
23 char *status_command;
24 bool pango_markup;
25 uint32_t position;
26 char *font;
27 char *sep_symbol;
28 char *mode;
29 bool strip_workspace_numbers;
30 bool binding_mode_indicator;
31 bool wrap_scroll;
32 bool workspace_buttons;
33 bool all_outputs;
34 list_t *outputs;
35
36 int height;
37
38 struct {
39 uint32_t background;
40 uint32_t statusline;
41 uint32_t separator;
42
43 struct box_colors focused_workspace;
44 struct box_colors active_workspace;
45 struct box_colors inactive_workspace;
46 struct box_colors urgent_workspace;
47 struct box_colors binding_mode;
48 } colors;
49};
50
51/**
52 * Parse position top|bottom|left|right.
53 */
54uint32_t parse_position(const char *position);
55
56/**
57 * Parse font.
58 */
59char *parse_font(const char *font);
60
61/**
62 * Initialize default sway config.
63 */
64struct config *init_config();
65
66/**
67 * Free config struct.
68 */
69void free_config(struct config *config);
70
71#endif /* _SWAYBAR_CONFIG_H */
diff --git a/include/swaybar/ipc.h b/include/swaybar/ipc.h
new file mode 100644
index 00000000..c11931d0
--- /dev/null
+++ b/include/swaybar/ipc.h
@@ -0,0 +1,23 @@
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, const char *bar_id);
10
11/**
12 * Handle ipc event from sway.
13 */
14bool handle_ipc_event(struct bar *bar);
15
16
17/**
18 * Send workspace command to sway
19 */
20void ipc_send_workspace_command(const char *workspace_name);
21
22#endif /* _SWAYBAR_IPC_H */
23
diff --git a/include/swaybar/render.h b/include/swaybar/render.h
new file mode 100644
index 00000000..114f43f4
--- /dev/null
+++ b/include/swaybar/render.h
@@ -0,0 +1,22 @@
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/**
18 * Compute the size of a workspace name
19 */
20void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height);
21
22#endif /* _SWAYBAR_RENDER_H */
diff --git a/include/swaybar/status_line.h b/include/swaybar/status_line.h
new file mode 100644
index 00000000..9b77e8a7
--- /dev/null
+++ b/include/swaybar/status_line.h
@@ -0,0 +1,51 @@
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 bool markup;
27 // Airblader features
28 uint32_t background;
29 uint32_t border;
30 int border_top;
31 int border_bottom;
32 int border_left;
33 int border_right;
34};
35
36/**
37 * Initialize status line struct.
38 */
39struct status_line *init_status_line();
40
41/**
42 * handle status line activity.
43 */
44bool handle_status_line(struct bar *bar);
45
46/**
47 * Free status line struct.
48 */
49void free_status_line(struct status_line *line);
50
51#endif /* _SWAYBAR_STATUS_LINE_H */