Commit Graph

119 Commits

Author SHA1 Message Date
Erik Reider c60a8e9836 free pipewire listeners on proxy destruction 2023-10-31 08:52:54 +01:00
Erik Reider d32da917e4 Added tooltips 2023-10-29 00:17:53 +02:00
Erik Reider 4a4c888d7d Fixed linter complaining 2023-10-27 00:01:40 +02:00
Erik Reider f7224d8459 Initial implementation 2023-10-26 23:22:02 +02:00
Alexis Rouillard 2d33c20231
Revert "Fix potential memory leaks" 2023-10-22 09:44:46 +02:00
Alexis Rouillard 06f4028697
Merge pull request #2588 from taminob/bugfix/fix-custom-module-signal-without-interval
Custom module: Allow signal without interrupt
2023-10-21 14:09:12 +02:00
Tamino Bauknecht 8c57756556
util: add scope_guard
This custom small implementation avoids adding an extra dependency like
Boost.ScopeExit
2023-10-21 11:50:06 +02:00
Tamino Bauknecht b8afde043c
sleeper_thread: allow interrupting sleep()
This keeps the function consistent with sleep_until() and sleep_for()
which both can be interrupted.
This is relevant to allow an update via a "signal" without an "interval"
in a custom module.
2023-10-20 23:57:54 +02:00
Brenno Lemos ecbcf242d5 feat: allow unmuting by moving the pulseaudio slider 2023-10-15 17:52:12 -03:00
Brenno Lemos 11d7ca1d73 feat: backlight slider 2023-10-15 17:52:12 -03:00
Brenno Lemos c3779dd16e refactor: move backlight backend out of backlight module 2023-10-15 17:52:12 -03:00
Brenno Lemos 442a4b0da0 feat: pulseaudio slider module 2023-10-15 17:52:12 -03:00
Brenno Lemos c9e129cda2 feat: allow setting volume directly 2023-10-15 17:52:12 -03:00
Brenno Lemos 64d7fae03a refactor: move pulseaudio handling to separate class 2023-10-15 17:52:12 -03:00
Brenno Lemos c59264d6b4 fix: clang < 16 can't emplace back struct with no constructor 2023-10-12 17:30:32 -03:00
Brenno Lemos 387e54498e docs: document new regex collection class 2023-10-09 14:46:57 -03:00
Brenno Lemos 8d057e6f96 refactor: separate regex rule matching and caching in separate class 2023-10-09 13:53:00 -03:00
Brenno Lemos adbc9d95de feat: optional default icon for 0-match classes
Co-authored-by: Gabriel Fox <Inbox@GabrielFox.Dev>
2023-09-22 19:16:59 -03:00
Evan Overman 7c28ffc856
add indefinite `sleep()` function to `SleeperThread` 2023-09-18 14:55:50 -07:00
Alexis Rouillard fc67558717
Merge branch 'master' into darkmode 2023-09-11 09:25:45 +02:00
Austin Horstman 79cf33b9f1
refactor: enumparser create implementation file 2023-09-09 17:59:40 -05:00
Austin Horstman b8630968b2
refactor: move capitalize string helper 2023-09-09 13:23:17 -05:00
Austin Horstman 2fee12d930
fix: enumparser capitalize everything to avoid issues 2023-09-09 12:14:52 -05:00
Austin Horstman 3ae2fe3272
refactor: PR review cleanup 2023-09-09 12:08:30 -05:00
Austin Horstman 2b8c92e8fd
refactor: enum utility allow overriding 2023-09-09 11:18:12 -05:00
Austin Horstman 8ce64ea784
refactor: make parsing sort-by more lenient 2023-09-09 10:04:49 -05:00
Austin Horstman 8ea2626de8
refactor: sort-by enum hyprland 2023-09-09 10:04:48 -05:00
Calvin Lee 09873f0ed9 search for dark or light mode stylesheet
summary:
-------
This commit adds xdg-desktop-portal support to waybar. If a portal
supporting `org.freedesktop.portal.Settings` exists, then it will be
queried for the current colorscheme. This colorscheme will then be used
to prefer a `style-light.css` or `style-dark.css` over the basic
`style.css`.

technical details:
-----------------
Appearance is provided by several libraries, such as libhandy (mobile)
and libadwaita. However, waybar links to neither of these libraries. As
the amount of code required to communicate with xdg-desktop portal as a
client is rather minimal, I believe doing so is better than linking to
an additional library.

The Gio library for communicating with dbus is rather messy, Instead of
the `Portal` class containing a `Gio::Dbus::Proxy`, it extends it which
simplifies signal handling.

`Portal` then exposes its own signal, which can be listened to by waybar
to update CSS.

For a reference implementation, please see another one of my projects:
https://github.com/4e554c4c/darkman.nvim/blob/main/portal.go

test plan:
---------
If no desktop portal which provides `Settings` exists, then waybar
continues with the log line
```
[2023-09-06 14:14:37.754] [info] Unable to receive desktop appearance: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface “org.freedesktop.portal.Settings” on object at path /org/freedesktop/portal/desktop
```

Furthermore, if `style-light.css` or `style-dark.css` do not exist, then
`style.css` will still be searched for.

Waybar has been tested with both light and dark startup. E.g. if the
appearance is dark on startup the log lines
```
[2023-09-06 14:27:45.379] [info] Discovered appearance 'dark'
[2023-09-06 14:27:45.379] [debug] Try expanding: $XDG_CONFIG_HOME/waybar/style-dark.css
[2023-09-06 14:27:45.379] [debug] Found config file: $XDG_CONFIG_HOME/waybar/style-dark.css
[2023-09-06 14:27:45.379] [info] Using CSS file /home/pounce/.config/waybar/style-dark.css
```
will be observed.
If the color then changes to light during the operation of waybar, it
will change css files:
```
[2023-09-06 14:28:17.173] [info] Received new appearance 'dark'
[2023-09-06 14:28:17.173] [debug] Try expanding: $XDG_CONFIG_HOME/waybar/style-light.css
[2023-09-06 14:28:17.173] [debug] Found config file: $XDG_CONFIG_HOME/waybar/style-light.css
[2023-09-06 14:28:17.173] [info] Using CSS file /home/pounce/.config/waybar/style-light.css
```

Finally, tested resetting waybar and toggling style (works, and style is
only changed once).

fixes: Alexays/Waybar#1973
2023-09-06 15:19:56 +00:00
Jan Palus c8237437d2
Explicitly cast ustring to string when passing to fmt
don't rely on implicit conversion which is no longer present in fmt
10.1.0

Fixes #2403
2023-08-15 20:57:07 +02:00
Patrick Nicolas f62b3d0e9d Ensure signal is disconnected in destructor 2023-07-16 23:29:28 +02:00
Alex 6c196b8f8d fix: lint 2023-07-04 22:35:27 +02:00
André Aparício a1cd0acac5 Fix random segfault on GTK icon functions
The segfaults were happening on GTK icon theme functions, which are
called via the C++ interface functions such as Gtk::IconTheme::has_icon.

There are multiple modules and threads using this functions on the default
icon theme by calling Gtk::IconTheme::get_default(), which returns the same
object for all callers, and was causing concurrent access to the same internal
data structures on the GTK lib. Even a seemingly read-only function such as
has_icon can cause writes due to the internal icon cache being updated.

To avoid this issues, a program wide global mutex must be used to ensure
a single thread is accessing the default icon theme instance.

This commit implements wrappers for the existing IconTheme function calls,
ensuring the global lock is held while calling the underling GTK functions.
2023-07-03 22:32:24 +01:00
Patrick Nicolas 3c9cbc99d7 Wake all sleeping threads when leaving suspend
std::condition_variable::wait_for does not count time spent in sleep
mode, resulting in longer than expected waits.
2023-06-07 10:17:42 +02:00
Alex 097cbc0c53 fix: lint 2023-05-29 09:24:33 +02:00
cptpcrd 5cbbfd5c8a Close pipe if fork() fails when spawning processes
Prevents potential file descriptor leakage, albeit in a bit of an edge
case.
2023-05-21 12:15:49 -04:00
cptpcrd df65cab17a Open command pipes as close-on-exec
Avoids a race where the pipe could be inherited by another process
spawning at about the same time. If the other process didn't exit
quickly (e.g. if it was a custom script that did its own looping), it
would keep the write end of the pipe open, and so reading from the pipe
to try to get the command's output would block.

This bug manifested as some custom modules randomly not appearing in the
bar, requiring a reload to fix. The custom script had run and exited,
but the pipe had been inherited by another process, and the thread that
updated the module's output was blocked trying to read from it.
2023-05-21 12:10:44 -04:00
Alex a6084ea7e6
Merge pull request #2068 from TheRealLorenz/master 2023-04-03 09:44:04 +02:00
Alex 60e0584d16 fix: lint 2023-04-03 09:41:24 +02:00
TheRealLorenz 63525ec956 Rename function name 2023-03-25 17:33:01 +01:00
Aleksei Bavshin 93e340a081
feat(clock): support chrono Time Zone extensions.
Use chrono Calendars and Time Zones (P0355R7, P1466R3) when available
instead of the `date` library.
Verified with a patched build of a recent GCC 13 snapshot.
2023-01-21 02:18:44 -08:00
Aleksei Bavshin ea17a66dfc
fix: compilation errors with cpp_std=c++20
There were two main issues with fmtlib and C++20 mode:

 - `fmt::format` defaults to compile-time argument checking and requires
   using `fmt::runtime(format_string)` to bypass that.
 - `std::format` implementation introduces conflicting declarations and
   we have to specify the namespace for all `format`/`format_to` calls.
2023-01-20 22:50:02 -08:00
Aleksei Bavshin 67efe1af89
refactor(clock): remove struct waybar_time
The structure was used to pass the locale instance to the date
formatter. All the supported versions of `fmt` are passing the locale
parameter via `FormatContext.locale()` so we can remove the struct and
simplify the code.

While we at it, drop `date::make_zoned` in favor of CTAD on a
`date::zoned_time` constructor.
2023-01-20 22:50:01 -08:00
herlev 54e04b5a30 Refactor rewriteTitle 2022-10-19 13:25:08 +02:00
Alex 8551c4bbe3 fix: lint 2022-10-17 09:19:00 +02:00
Alex 58362abfaf
Merge pull request #1630 from duxovni/pow_format 2022-10-17 09:16:47 +02:00
Mika Braunschweig f86dff60e6
utils: add sanitize_str to encode '&' etc.
gtk requires some chars (<>&"') to be encoded for them to render
properly. `sanitize_str` sanitizes raw strings that have such chars and
returns a properly encoded string
2022-10-17 00:31:19 +02:00
Faye Duxovni e14005a6aa Fix binary pow formatting for values between 1000 and 1024 2022-07-21 16:37:43 -04:00
Aleksei Bavshin 24a8332b62
fix: adapt to fmt 9.0.0 breaking changes 2022-07-13 22:36:32 -07:00
Alex f2fcadbf62 refactor: lint 2022-04-06 08:37:19 +02:00
Alex be1d2a02ca
Merge pull request #1422 from technic/fixes
minor string utils methods refactoring
2022-03-06 14:50:02 +01:00