diff options
author | Luke Drummond <ldrumm@rtps.co> | 2020-06-11 01:29:07 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-06-12 14:45:40 +0200 |
commit | c22caa54a8b40e152b141c18d32f3bad383d9d1c (patch) | |
tree | 3cfe6163f09beb36adbf6c84e371c43ecec6a577 /swaybar/bar.c | |
parent | Log Sway version on startup (diff) | |
download | sway-c22caa54a8b40e152b141c18d32f3bad383d9d1c.tar.gz sway-c22caa54a8b40e152b141c18d32f3bad383d9d1c.tar.zst sway-c22caa54a8b40e152b141c18d32f3bad383d9d1c.zip |
swaybar: ensure correct init order for status_line
`$WAYLAND_SOCKET` is unset by `wl_display_connect` after it has
successfully connected to the wayland socket.
However, subprocesses spawned by swaybar (status-command) don't have
access to waybar's fds as $WAYLAND_SOCKET is O_CLOEXEC. This means any
status command which itself tries to connect to wayland will fail if
this environment variable is set.
Reorder display and status-command initialization so that this variable
is not set and add an assert so we can enforce this invariant in future.
Diffstat (limited to 'swaybar/bar.c')
-rw-r--r-- | swaybar/bar.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index f4dd4405..231c1ad7 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -413,10 +413,6 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { | |||
413 | if (!ipc_initialize(bar)) { | 413 | if (!ipc_initialize(bar)) { |
414 | return false; | 414 | return false; |
415 | } | 415 | } |
416 | if (bar->config->status_command) { | ||
417 | bar->status = status_line_init(bar->config->status_command); | ||
418 | bar->status->bar = bar; | ||
419 | } | ||
420 | 416 | ||
421 | bar->display = wl_display_connect(NULL); | 417 | bar->display = wl_display_connect(NULL); |
422 | if (!bar->display) { | 418 | if (!bar->display) { |
@@ -445,6 +441,11 @@ bool bar_setup(struct swaybar *bar, const char *socket_path) { | |||
445 | assert(pointer->cursor_surface); | 441 | assert(pointer->cursor_surface); |
446 | } | 442 | } |
447 | 443 | ||
444 | if (bar->config->status_command) { | ||
445 | bar->status = status_line_init(bar->config->status_command); | ||
446 | bar->status->bar = bar; | ||
447 | } | ||
448 | |||
448 | #if HAVE_TRAY | 449 | #if HAVE_TRAY |
449 | if (!bar->config->tray_hidden) { | 450 | if (!bar->config->tray_hidden) { |
450 | bar->tray = create_tray(bar); | 451 | bar->tray = create_tray(bar); |