aboutsummaryrefslogtreecommitdiff
path: root/swaybar/status_line.c
AgeCommit message (Collapse)AuthorLines
2024-02-16Define _POSIX_C_SOURCE globallyFurkan Sahin-1/+0
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2021-12-21swaybar: fix errno handling in status_handle_readableFurkan Sahin-1/+1
If getline fails once, it was not reset before the next getline call. errno is only overwritten by getline on error.
2021-11-21swaybar: signal status command's process groupFurkan Sahin-3/+8
Make the status command a process group leader and change the kill(2) calls to target the new process group. Signals sent by swaybar will then be received by both the status command and its children, if any. While here, check the result of fork(2). Without this, children spawned by the status command may not receive the signals sent by swaybar. As a result, these children may be orphaned on reload. The issue could be shown by setting the bar to bar { status_command i3status | tee /tmp/i3status.out } which would leave orphaned processes for each reload of sway $ ps o pid,ppid,cmd | grep i3status | grep -v grep 43633 43624 sh -c i3status | tee /tmp/i3status.out 43634 43633 i3status 43635 43633 tee /tmp/i3status.out $ swaymsg reload $ ps o pid,ppid,cmd | grep i3status | grep -v grep 43634 1 i3status 43635 1 tee /tmp/i3status.out 43801 43788 sh -c i3status | tee /tmp/i3status.out 43802 43801 i3status 43803 43801 tee /tmp/i3status.out This fixes #5584.
2020-07-11swaybar: allow status line cleanup to proceed when hiddenFurkan Sahin-0/+1
`determine_bar_visibility` stops and starts the status command process according to the bar’s visibility. If the bar was hidden during teardown, teardown would stall while waiting for the stopped status command process to exit. This resumes a stopped status command during teardown and allows, for example, sway to reload or quit without leaving a swaybar instance behind each time. Fixes #5536. CONT before TERM as requested in review.
2020-06-11swaybar: ensure correct init order for status_lineFurkan Sahin-0/+3
`$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.
2020-02-01swaybar: fix i3bar relative coordinates when scaling is usedFurkan Sahin-0/+7
f533de1e59135e3b5701e61cade30942e3378074 did not take scaling into account. The hotspot size used pixel coordinates, the absolute coordinates were logical, and the relative coordinates were completely wrong. This commit makes all coordinates use logical values. If `"float_event_coords":true` is sent in the handshake message, coordinates are sent as floating-point values. The "scale" field is an integer containing the scale value.
2019-09-02swaybar: complete barconfig_update event handlingFurkan Sahin-0/+3
This adds complete support for the barconfig_update ipc event. This also changes the bar command and subcommand handlers to correctly emit the event. This makes it so all bar subcommands other than id and swaybar_command are dynamically changeable at runtime. sway-bar.5 has been updated accordingly
2019-02-01Revert "More frees."Furkan Sahin-2/+0
This reverts commit 99b819f3d7f5b0a387a2c68548cafaf882f323f3.
2019-01-23Make json-c include respect pkg-config --cflagsFurkan Sahin-1/+1
json-c.pc contains `Cflags: -I${includedir}/json-c`, so `<json-c/json.h>` won't be found unless the parent directory is searched by default.
2019-01-20Replace wlr_log with sway_logFurkan Sahin-9/+9
This commit mostly duplicates the wlr_log functions, although with a sway_* prefix. (This is very similar to PR #2009.) However, the logging function no longer needs to be replaceable, so sway_log_init's second argument is used to set the exit callback for sway_abort. wlr_log_init is still invoked in sway/main.c This commit makes it easier to remove the wlroots dependency for the helper programs swaymsg, swaybg, swaybar, and swaynag.
2018-12-09Remove readline.cFurkan Sahin-1/+0
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
2018-12-31swaybar: fix double freeFurkan Sahin-1/+0
status->text should not be freed here. There are two scenarios: * status->text has been set to an error by status_error. In this case the value shouldn't be freed because it's always a reference to a constant. * status->text has been set to status->buffer because the bar is in text protocol mode. In this case it's a double free because the buffer is already freed after.
2018-11-13More frees.Furkan Sahin-0/+3
2018-10-14Remove timerfd from loop implementationFurkan Sahin-1/+1
timerfd doesn't work on the BSDs, so this replaces it with a timespec for the expiry and uses a poll timeout to check the timers when needed.
2018-10-13Move swaybar's event loop to common directory and refactorFurkan Sahin-2/+2
* The loop functions are now prefixed with `loop_`. * It is now easy to add timers to the loop. * Timers are implemented using pollfd and timerfd, rather than manually checking them when any other event happens to arrive.
2018-10-12swaybar: send signal to status when hiding or showing barFurkan Sahin-0/+14
2018-09-24swaybar: move i3bar definitions into separate fileFurkan Sahin-0/+2
2018-09-26Replace getdelim to make swaybar work on FreeBSDFurkan Sahin-13/+27
This commit fixes a segfault in swaybar on FreeBSD that was caused by using getdelim with EOF as delimiter on an infinite stream. The FreeBSD implementation handles the "no more data, delimiter not found, and EOF not reached" scenario as an error, so it can't be used to read the output of status command. This commit replaces the getline/getdelim calls with reading all available data from the stream in one go.
2018-09-22swaybar: explicitly check return value of getdelimFurkan Sahin-3/+7
This prevents an signed-to-unsigned conversion error on buffer_index if getdelim fails and returns -1, which caused swaybar to try to search the header for the array and immediately failing
2018-09-18swaybar: only free tokener when using i3bar protocolFurkan Sahin-1/+1
2018-09-17swaybar: rewrite i3bar protocol handlingFurkan Sahin-21/+10
This now correctly handles an incoming json infinite array by shifting most of the heavy listing to the json-c parser, as well as sending multiple statuses at once. It also removes the struct i3bar_protocol_state and moves its members into the status_line struct, allowing the same buffer to be used for both protocols.
2018-09-17swaybar: rewrite protocol determinationFurkan Sahin-31/+33
This now uses the getline function to receive the header, replacing read_line_buffer, which has been deleted since it is otherwise unused. Furthermore, once the protocol has been determined, the current status is handled immediately to be shown (though this has not been added for the i3bar protocol since it has not yet been rewritten to handle this).
2018-09-17swaybar: rewrite text protocol handlingFurkan Sahin-16/+24
This now uses getline to correctly handle multiple or long statuses. It also removes the struct text_protocol_state and moves its members into the status_line struct.
2018-09-15swaybar: invalidate file descriptors upon closingFurkan Sahin-4/+15
2018-09-15swaybar: remove block links upon exitFurkan Sahin-1/+3
2018-09-12i3bar: count references to blocksFurkan Sahin-1/+1
This prevents blocks from being destroyed before their hotspots are destroyed, in case it is used for a pending click event that fires between the bar receiving a new status, which destroys the block, and the bar rendering the new status, which destroys the hotspot; this problem can be easily produced by scrolling on a block that immediately causes a new status to be sent, with multiple outputs
2018-07-09Update for swaywm/wlroots#1126Furkan Sahin-3/+3
2018-04-24Fix a bunch of swaybar memory leaksFurkan Sahin-1/+13
2018-04-15Set _POSIX_C_SOURCE properlyFurkan Sahin-1/+1
2018-04-03Fix #1709Furkan Sahin-1/+5
2018-03-31Render i3bar blocksFurkan Sahin-2/+3
2018-03-31Demarcate i3bar JSON into individual updatesFurkan Sahin-9/+53
2018-03-29Do some small cleanupFurkan Sahin-0/+1
- Fix workspace events (security config isn't in use so it wasn't being sent) - Kill status bar process when swaybar exits - Don't rearrange windows on every layer surface commit
2018-03-29Clean up status line on exitFurkan Sahin-2/+4
2018-03-29Implement status lineFurkan Sahin-0/+78
Does not yet support i3bar json protocol
2018-03-28Start port of swaybar to layer shellFurkan Sahin-530/+0
This starts up the event loop and wayland display and shims out the basic top level rendering concepts. Also includes some changes to incorporate pango into the 1.x codebase properly.
2017-10-28Removed trailing comma from swaybar click event jsonFurkan Sahin-1/+1
2017-10-14Fix build on FreeBSD adjusting/removing _XOPEN_SOURCE declaration.Furkan Sahin-1/+1
2017-08-30styling fixesFurkan Sahin-2/+2
2017-08-29styling fixesFurkan Sahin-1/+1
2017-08-29style fixesFurkan Sahin-2/+1
2017-08-29click_events as documented at https://i3wm.org/docs/i3bar-protocol.htmlFurkan Sahin-2/+80
2017-03-10UnGNUify the codebaseFurkan Sahin-0/+1
2016-09-01Reorganize includesFurkan Sahin-2/+2
2016-07-30implement solid color rendering for swaybgFurkan Sahin-0/+1
2016-04-24Use i3bar format for markup field.Furkan Sahin-1/+5
In the i3bar protocol the value of the markup field is a string: "pango" or "none" rather than a bool. This patch makes swaybar compatible with that. http://i3wm.org/docs/i3bar-protocol.html
2016-04-17Flesh out pango markup implementationFurkan Sahin-1/+6
2016-01-24swaybar: move headers to include/barFurkan Sahin-2/+2
2016-01-24swaybar: rename state to barFurkan Sahin-29/+29
2016-01-24swaybar: Move swaybar_teardown to free_stateFurkan Sahin-0/+7