diff options
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 10 | ||||
-rw-r--r-- | swaybar/bar.h | 55 | ||||
-rw-r--r-- | swaybar/config.c | 2 | ||||
-rw-r--r-- | swaybar/config.h | 69 | ||||
-rw-r--r-- | swaybar/ipc.c | 4 | ||||
-rw-r--r-- | swaybar/ipc.h | 17 | ||||
-rw-r--r-- | swaybar/main.c | 2 | ||||
-rw-r--r-- | swaybar/render.c | 6 | ||||
-rw-r--r-- | swaybar/render.h | 17 | ||||
-rw-r--r-- | swaybar/status_line.c | 4 | ||||
-rw-r--r-- | swaybar/status_line.h | 50 |
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 | ||
17 | static void bar_init(struct bar *bar) { | 17 | static 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 | |||
8 | struct 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 | |||
20 | struct output { | ||
21 | struct window *window; | ||
22 | struct registry *registry; | ||
23 | list_t *workspaces; | ||
24 | char *name; | ||
25 | }; | ||
26 | |||
27 | struct workspace { | ||
28 | int num; | ||
29 | char *name; | ||
30 | bool focused; | ||
31 | bool visible; | ||
32 | bool urgent; | ||
33 | }; | ||
34 | |||
35 | /** | ||
36 | * Setup bar. | ||
37 | */ | ||
38 | void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id, int desired_output); | ||
39 | |||
40 | /** | ||
41 | * Bar mainloop. | ||
42 | */ | ||
43 | void bar_run(struct bar *bar); | ||
44 | |||
45 | /** | ||
46 | * free workspace list. | ||
47 | */ | ||
48 | void free_workspaces(list_t *workspaces); | ||
49 | |||
50 | /** | ||
51 | * Teardown bar. | ||
52 | */ | ||
53 | void 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 | ||
8 | uint32_t parse_color(const char *color) { | 8 | uint32_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 | */ | ||
10 | struct box_colors { | ||
11 | uint32_t border; | ||
12 | uint32_t background; | ||
13 | uint32_t text; | ||
14 | }; | ||
15 | |||
16 | /** | ||
17 | * Swaybar config. | ||
18 | */ | ||
19 | struct 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 | */ | ||
47 | uint32_t parse_color(const char *color); | ||
48 | |||
49 | /** | ||
50 | * Parse position top|bottom|left|right. | ||
51 | */ | ||
52 | uint32_t parse_position(const char *position); | ||
53 | |||
54 | /** | ||
55 | * Parse font. | ||
56 | */ | ||
57 | char *parse_font(const char *font); | ||
58 | |||
59 | /** | ||
60 | * Initialize default sway config. | ||
61 | */ | ||
62 | struct config *init_config(); | ||
63 | |||
64 | /** | ||
65 | * Free config struct. | ||
66 | */ | ||
67 | void 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 | ||
10 | static void ipc_parse_config(struct config *config, const char *payload) { | 10 | static 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 | */ | ||
9 | void ipc_bar_init(struct bar *bar, int outputi, const char *bar_id); | ||
10 | |||
11 | /** | ||
12 | * Handle ipc event from sway. | ||
13 | */ | ||
14 | bool 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 */ |
11 | struct bar swaybar; | 11 | struct 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 | */ | ||
10 | void render(struct output *output, struct config *config, struct status_line *line); | ||
11 | |||
12 | /** | ||
13 | * Set window height and modify internal spacing accordingly. | ||
14 | */ | ||
15 | void 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 | |||
10 | typedef enum {UNDEF, TEXT, I3BAR} command_protocol; | ||
11 | |||
12 | struct status_line { | ||
13 | list_t *block_line; | ||
14 | const char *text_line; | ||
15 | command_protocol protocol; | ||
16 | }; | ||
17 | |||
18 | struct 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 | */ | ||
38 | struct status_line *init_status_line(); | ||
39 | |||
40 | /** | ||
41 | * handle status line activity. | ||
42 | */ | ||
43 | bool handle_status_line(struct bar *bar); | ||
44 | |||
45 | /** | ||
46 | * Free status line struct. | ||
47 | */ | ||
48 | void free_status_line(struct status_line *line); | ||
49 | |||
50 | #endif /* _SWAYBAR_STATUS_LINE_H */ | ||