diff options
author | crondog <crondog@gmail.com> | 2015-12-19 12:15:12 +1100 |
---|---|---|
committer | crondog <crondog@gmail.com> | 2015-12-19 12:15:12 +1100 |
commit | c8555f5813a728bc574c4a951856912b253fb1fb (patch) | |
tree | 3a9ba32e09313b02ba76469ab6b5d78ddfc0a295 /swaybar | |
parent | Just bail if ws_json is fucked up (diff) | |
download | sway-c8555f5813a728bc574c4a951856912b253fb1fb.tar.gz sway-c8555f5813a728bc574c4a951856912b253fb1fb.tar.zst sway-c8555f5813a728bc574c4a951856912b253fb1fb.zip |
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) { | |||
173 | return res; | 173 | return res; |
174 | } | 174 | } |
175 | 175 | ||
176 | uint32_t parse_position(const char *position) { | ||
177 | if (strcmp("top", position) == 0) { | ||
178 | return DESKTOP_SHELL_PANEL_POSITION_TOP; | ||
179 | } else if (strcmp("bottom", position) == 0) { | ||
180 | return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
181 | } else if (strcmp("left", position) == 0) { | ||
182 | return DESKTOP_SHELL_PANEL_POSITION_LEFT; | ||
183 | } else if (strcmp("right", position) == 0) { | ||
184 | return DESKTOP_SHELL_PANEL_POSITION_RIGHT; | ||
185 | } else { | ||
186 | return DESKTOP_SHELL_PANEL_POSITION_BOTTOM; | ||
187 | } | ||
188 | } | ||
189 | |||
176 | void bar_ipc_init(int outputi, const char *bar_id) { | 190 | void bar_ipc_init(int outputi, const char *bar_id) { |
177 | uint32_t len = 0; | 191 | uint32_t len = 0; |
178 | char *res = ipc_single_command(socketfd, IPC_GET_OUTPUTS, NULL, &len); | 192 | 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) { | |||
210 | status_command = strdup(json_object_get_string(_status_command)); | 224 | status_command = strdup(json_object_get_string(_status_command)); |
211 | } | 225 | } |
212 | 226 | ||
227 | if (position) { | ||
228 | desktop_shell_set_panel_position(registry->desktop_shell, parse_position(json_object_get_string(position))); | ||
229 | } | ||
230 | |||
213 | if (_colors) { | 231 | if (_colors) { |
214 | json_object *background, *statusline, *separator; | 232 | json_object *background, *statusline, *separator; |
215 | json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; | 233 | json_object *focused_workspace_border, *focused_workspace_bg, *focused_workspace_text; |
@@ -456,7 +474,6 @@ int main(int argc, char **argv) { | |||
456 | sway_abort("Failed to create window."); | 474 | sway_abort("Failed to create window."); |
457 | } | 475 | } |
458 | desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); | 476 | desktop_shell_set_panel(registry->desktop_shell, output->output, window->surface); |
459 | desktop_shell_set_panel_position(registry->desktop_shell, DESKTOP_SHELL_PANEL_POSITION_BOTTOM); | ||
460 | 477 | ||
461 | int width, height; | 478 | int width, height; |
462 | get_text_size(window, &width, &height, "Test string for measuring purposes"); | 479 | get_text_size(window, &width, &height, "Test string for measuring purposes"); |