aboutsummaryrefslogtreecommitdiff
path: root/swaynag/config.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
2023-11-03swaynag/config.c: fix build against gcc-14 (-Walloc-size)Furkan Sahin-1/+1
`gcc-14` added a new `-Walloc-size` warning that makes sure that size of an individual element matches size of a pointed type: https://gcc.gnu.org/PR71219 `sway` triggers it on `calloc()` calls where member size is used as `1` (instead of member count): swaynag/config.c:169:65: error: allocation of insufficient size '1' for type 'struct swaynag_button' with size '48' [-Werror=alloc-size] 169 | struct swaynag_button *button = calloc(sizeof(struct swaynag_button), 1);
2023-01-08swaynag: call swaynag_destroy on clean exitFurkan Sahin-2/+2
And fix the fallout of the swaynag_destroy having evolved without being tested: * wl_display_disconnect was called too early * `button_close` and `swaynag.details.button_details` needed to be heap allocated, since they are added to swaynag.buttons, and all entries of swaynag.buttons are freed in swaynag_destroy * To keep things simpler, disconnect the lifetime of the 'Toggle details' button text config setting from the button itself.
2022-12-21swaynag: drop swaynag_type.fontFurkan Sahin-3/+1
It's too easy to have this go out of sync with font_description.
2022-07-01Reuse parsed PangoFontDescriptionFurkan Sahin-0/+2
Avoids parsing the configured font each time text is rendered.
2022-03-20swaynag: combine consecutive declaration/assignmentsFurkan Sahin-4/+2
2022-03-18swaynag: improve robustness when loading configFurkan Sahin-12/+5
2022-03-17swaynag: do error checking and rename read_from_stdinFurkan Sahin-11/+23
read_from_stdin not only read from stdin, but trimming trailing newlines, so rename it to reflect this.
2022-02-28swaynag: allocate button_details with detailsFurkan Sahin-2/+2
They are used together, so it doesn't make sense to allocate them separately.
2022-02-25swaynag: die on all allocation failuresFurkan Sahin-0/+19
2022-02-08Remove all sprintf callsFurkan Sahin-2/+2
Replace them with snprintf, which ensures buffer overflows won't happen.
2021-03-17swaynag: adds option to set wayland shell layerFurkan Sahin-1/+22
Uses --layer/-y set to overlay|top|bottom|background
2021-02-03Make command line option lists constFurkan Sahin-1/+1
2021-01-16Changed fprintf(stdout,...) to printf(...) for more readable codeFurkan Sahin-1/+1
2020-09-08swaynag: add details background optionFurkan Sahin-0/+8
Adds a new config option for details background for swaynag issue/#5673
2020-09-02swaynag: adds option to separately specify the text color for buttonsFurkan Sahin-25/+33
2020-06-07swaynag: allow specifying more buttons which execute and dismissFurkan Sahin-1/+11
I don't love -z / -Z, but I figure this patch is far from being accepted for other reasons too.
2019-12-27parse_color: return success + drop fallback colorFurkan Sahin-10/+10
This is the first in a series of commits to refactor the color handling in sway. This changes parse_color to return whether it was success and no longer uses 0xFFFFFFFF as the fallback color. This also verifies that the string actually contains a valid hexadecimal number along with the length checks. In the process of altering the calls to parse_color, I also took the opportunity to heavily refactor swaybar's ipc_parse_colors function. This allowed for several lines of duplicated code to be removed.
2019-04-19swaynag: revamp type configsFurkan Sahin-5/+2
This revamps the type configs for swaynag. All sizing attributes for swaynag are now `ssize_t` instead of `uint32_t` to allow for a default value of `-1`, which allows for `0` to be a valid value. Additionally, the initialization of the type configs has been changed from a simple calloc to use a new function `swaynag_type_new`. `swaynag_type_new` calloc's the memory, checks for an allocation failure, sets the name, and all sizes to -1. The layering order has also been changed to default, general config, type config, and as highest priority command line arguments. Finally, `swaynag_type_merge` has been modified to handle the layering and sizing changes.
2019-03-11Repair swaynag crash reading message from stdinFurkan Sahin-1/+1
When swaynag is run with the -l/--detailed-message option, a crash may occur if the detailed message read from stdin is large enough. E.g.: swaynag -m hello -l < ~/.config/sway/config The root cause is that the read_from_stdin() function under-allocates memory for the destination buffer which causes that buffer to be overflowed when copying line data to it with snprintf(). The repair is to allocate one more byte for the terminating null byte. N.B. although getline() returns the number of bytes read excluding a terminating null byte, the line buffer is terminated with a null byte. Thus we have a guarantee that the line buffer will be null terminated (which is important when copying with snprintf()).
2019-02-05swaynag: remove trailing newlines in configFurkan Sahin-0/+4
Now that swaynag uses getline (instead of the old readline), the trailing newline characters have to be removed when reading the config
2019-01-23Fix build failure in config.cFurkan Sahin-0/+1
2019-01-19swaynag: fix XDG_CONFIG_HOME handlingFurkan Sahin-1/+1
2019-01-16Remove usage of VLAs.Furkan Sahin-1/+2
2019-01-14swaynag: handle empty $XDG_CONFIG_HOME betterFurkan Sahin-14/+4
Set config path to fallback instead of setting $XDG_CONFIG_HOME
2018-12-09Remove readline.cFurkan Sahin-38/+24
All occurrences of read_line have been replaced by getline. peek_line has been absorbed into detect_brace.
2018-11-27Implement swaynag -B/--button-no-terminalFurkan Sahin-2/+8
In `i3 4.16`, `i3-nagbar` introduces the flags `-B/--button-no-terminal` to run the action directly instead of inside a terminal. This implements the flags for swaynag for compatibility. Since swaynag does not use an equivalent to `i3-sensible-terminal`, the flags `-b/--button` only uses a terminal when the environment variable `TERMINAL` is set, otherwise it acts the same as these new flags.
2018-11-25Replace _XOPEN_SOURCE with _POSIX_C_SOURCEFurkan Sahin-3/+1
And make sure we don't define both in the same source file.
2018-09-30Turn funcs() into funcs(void)Furkan Sahin-1/+1
If they really do not take undefined number of arguments.
2018-08-20Fix bad-free in swaynagFurkan Sahin-2/+2
2018-08-01swaynag: don't drop \n for first lineFurkan Sahin-8/+4
2018-07-29swaynag: allow more config optionsFurkan Sahin-18/+131
2018-07-28swaynag: refactor {sway_,}nagbar to swaynagFurkan Sahin-40/+40
2018-07-28swaynag: split config into own file and fix optindFurkan Sahin-0/+292