Moving rfkill to the main event loop had unexpected side-effects.
Notably, the network module mutex can block all the main thread events
for several seconds while the network worker thread is sleeping.
Instead of waiting for the mutex let's hope that the worker thread
succeeds and schedule timer thread wakeup just in case.
Open rfkill device only once per module.
Remove rfkill threads and use `Glib::signal_io` as a more efficient way
to poll the rfkill device.
Handle runtime errors from rfkill and stop polling of the device instead
of crashing waybar.
../src/modules/network.cpp:22:6: error: ‘optional’ in namespace ‘std’ does not name a template type
22 | std::optional<unsigned long long> read_netstat(std::string_view category, std::string_view key) {
| ^~~~~~~~
../src/modules/network.cpp:7:1: note: ‘std::optional’ is defined in header ‘<optional>’; did you forget to ‘#include <optional>’?
6 | #include "util/format.hpp"
+++ |+#include <optional>
7 | #ifdef WANT_RFKILL
This will enable the networking module to be used for ethernet
interfaces on kernels without nl80211 support.
It should be reasonable to allow desktop systems without
wireless interfaces to run custom kenrel configs
without nl80211 compiled in.
Fixes:
../src/modules/network.cpp:68:3: error: 'assert' was not declared in this scope
68 | assert(starts_with(read, category));
| ^~~~~~
../src/modules/network.cpp:6:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
5 | #include "util/format.hpp"
+++ |+#include <cassert>
6 |