diff options
Diffstat (limited to 'include/swaybar')
| -rw-r--r-- | include/swaybar/bar.h | 63 | ||||
| -rw-r--r-- | include/swaybar/config.h | 71 | ||||
| -rw-r--r-- | include/swaybar/ipc.h | 23 | ||||
| -rw-r--r-- | include/swaybar/render.h | 22 | ||||
| -rw-r--r-- | include/swaybar/status_line.h | 51 | 
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 @@ +#ifndef _SWAYBAR_BAR_H +#define _SWAYBAR_BAR_H + +#include "client/registry.h" +#include "client/window.h" +#include "list.h" + +struct bar { +	struct config *config; +	struct status_line *status; +	list_t *outputs; + +	int ipc_event_socketfd; +	int ipc_socketfd; +	int status_read_fd; +	pid_t status_command_pid; +}; + +struct output { +	struct window *window; +	struct registry *registry; +	list_t *workspaces; +	char *name; +	int idx; +}; + +struct workspace { +	int num; +	char *name; +	bool focused; +	bool visible; +	bool urgent; +}; + +/** Global bar state */ +extern struct bar swaybar; + +/** + * Setup bar. + */ +void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id); + +/** + * Create new output struct from name. + */ +struct output *new_output(const char *name); + +/** + * Bar mainloop. + */ +void bar_run(struct bar *bar); + +/** + * free workspace list. + */ +void free_workspaces(list_t *workspaces); + +/** + * Teardown bar. + */ +void bar_teardown(struct bar *bar); + +#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 @@ +#ifndef _SWAYBAR_CONFIG_H +#define _SWAYBAR_CONFIG_H + +#include <stdint.h> +#include <stdbool.h> + +#include "list.h" +#include "util.h" + +/** + * Colors for a box with background, border and text colors. + */ +struct box_colors { +	uint32_t border; +	uint32_t background; +	uint32_t text; +}; + +/** + * Swaybar config. + */ +struct config { +	char *status_command; +	bool pango_markup; +	uint32_t position; +	char *font; +	char *sep_symbol; +	char *mode; +	bool strip_workspace_numbers; +	bool binding_mode_indicator; +	bool wrap_scroll; +	bool workspace_buttons; +	bool all_outputs; +	list_t *outputs; + +	int height; + +	struct { +		uint32_t background; +		uint32_t statusline; +		uint32_t separator; + +		struct box_colors focused_workspace; +		struct box_colors active_workspace; +		struct box_colors inactive_workspace; +		struct box_colors urgent_workspace; +		struct box_colors binding_mode; +	} colors; +}; + +/** + * Parse position top|bottom|left|right. + */ +uint32_t parse_position(const char *position); + +/** + * Parse font. + */ +char *parse_font(const char *font); + +/** + * Initialize default sway config. + */ +struct config *init_config(); + +/** + * Free config struct. + */ +void free_config(struct config *config); + +#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 @@ +#ifndef _SWAYBAR_IPC_H +#define _SWAYBAR_IPC_H + +#include "bar.h" + +/** + * Initialize ipc connection to sway and get sway state, outputs, bar_config. + */ +void ipc_bar_init(struct bar *bar, const char *bar_id); + +/** + * Handle ipc event from sway. + */ +bool handle_ipc_event(struct bar *bar); + + +/** + * Send workspace command to sway + */ +void ipc_send_workspace_command(const char *workspace_name); + +#endif /* _SWAYBAR_IPC_H */ + 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 @@ +#ifndef _SWAYBAR_RENDER_H +#define _SWAYBAR_RENDER_H + +#include "config.h" +#include "bar.h" + +/** + * Render swaybar. + */ +void render(struct output *output, struct config *config, struct status_line *line); + +/** + * Set window height and modify internal spacing accordingly. + */ +void set_window_height(struct window *window, int height); + +/** + * Compute the size of a workspace name + */ +void workspace_button_size(struct window *window, const char *workspace_name, int *width, int *height); + +#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 @@ +#ifndef _SWAYBAR_STATUS_LINE_H +#define _SWAYBAR_STATUS_LINE_H + +#include <stdint.h> +#include <stdbool.h> + +#include "list.h" +#include "bar.h" + +typedef enum {UNDEF, TEXT, I3BAR} command_protocol; + +struct status_line { +	list_t *block_line; +	const char *text_line; +	command_protocol protocol; +}; + +struct status_block { +	char *full_text, *short_text, *align; +	bool urgent; +	uint32_t color; +	int min_width; +	char *name, *instance; +	bool separator; +	int separator_block_width; +	bool markup; +	// Airblader features +	uint32_t background; +	uint32_t border; +	int border_top; +	int border_bottom; +	int border_left; +	int border_right; +}; + +/** + * Initialize status line struct. + */ +struct status_line *init_status_line(); + +/** + * handle status line activity. + */ +bool handle_status_line(struct bar *bar); + +/** + * Free status line struct. + */ +void free_status_line(struct status_line *line); + +#endif /* _SWAYBAR_STATUS_LINE_H */  | 
