diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-18 20:24:05 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-18 20:24:05 -0500 |
commit | 155fb7a221eb4f4ec7c648f843c990a34871bf67 (patch) | |
tree | 3a9ba32e09313b02ba76469ab6b5d78ddfc0a295 /swaybar | |
parent | 859f2fea0c3dc4784990a14b033f89a7e7a1be61 (diff) | |
parent | c8555f5813a728bc574c4a951856912b253fb1fb (diff) |
Merge pull request #362 from crondog/master
swaybar: use position from config
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/main.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/swaybar/main.c b/swaybar/main.c index cd0bf0d3..7ac76dfa 100644 --- a/swaybar/main.c +++ b/swaybar/main.c @@ -173,6 +173,20 @@ uint32_t parse_color(const char *color) { return res; } +uint32_t parse_position(const char *position) { + if (strcmp("top", position) == 0) { + return DESKTOP_SHELL_PANEL_POSITION_TOP; + } else if (strcmp("bottom", position) == 0) { + return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; + } else if (strcmp("left", position) == 0) { + return DESKTOP_SHELL_PANEL_POSITION_LEFT; + } else if (strcmp("right", position) == 0) { + return DESKTOP_SHELL_PANEL_POSITION_RIGHT; + } else { + return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; + } +} + void bar_ipc_init(int outputi, const char *bar_id) { uint32_t len = 0; char *res = ipc_single_command(socketfd, IPC_GET_OUTPUTS, NULL, &len); @@ -210,6 +224,10 @@ void bar_ipc_init(int outputi, const char *bar_id) { status_command = strdup(json_object_get_string(_status_command)); } + if (position) { + desktop_shell_set_panel_position(registry->desktop_shell, parse_position(json_object_get_string(position))); + } + if (_colors) { json_object *background, *statusline, *separator; json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; @@ -456,7 +474,6 @@ int main(int argc, char **argv) { sway_abort("Failed to create window."); } desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); - desktop_shell_set_panel_position(registry->desktop_shell, DESKTOP_SHELL_PANEL_POSITION_BOTTOM); int width, height; get_text_size(window, &width, &height, "Test string for measuring purposes"); |