The module doesn't update the `essid_` as soon as a WiFi interface is
connected, but that happens at some point later, depending on
"interval" configuration.
Fix that by rerunning the get WiFi information thread when the
`carrier` state changes. Also, we will clear the state related to WiFi
when the connection is drop to avoid stale information.
Some RTM_NEWLINK messages may not have the IFLA_CARRIER information.
This is the case when a WiFi interface report scan result are
available. `carrier` is used regardless of if it is present in the
message or not. This would result in the interface appearing
"disconnected" in waybar when it isn't.
This patch now check that `carrier` is available before using it.
The same thing could potentially happen to `ifname` so check if it's
set before recording it.
Fixes: c1427ff (network: Handle carrier information)
Fixes#388
IFLA_CARRIER allows to know when a cable is plugged to the Ethernet
card or when the WiFi is connected. If there's no carrier, the
interface will be considered disconnected.
Last part of the rework of handleEvents(), this time we take the
getExternalInterface() function and add it to the handleEvents()
function. That way, waybar can react immediately when a new "external
interface" is available and doesn't need to probe. Also that avoid to
have two different functions consuming from the same socket and we
don't need to recode some of the functions that are already available
via libnl (to send and receive messages).
In order to get the IP address of an interface, we can get the
information out of NEWADDR events without needed to call getifaddrs().
And when now events are expected, we can requests a dump of all
addresses and handle addresses changes the same way via handleEvents()
only.
Instead of using an alternative way to list all links in order to
choose one when an "interface" is in the configuration, we can ask for
a dump of all interface an reuse the handleEvents() function.
This patch also start to rework the handleEvents() function to grab
more information out of each event, like the interface name.
When more than one message is available to read on the ev_sock_
socket, only the first one is read.
Make some changes to be able to read all the messages available by
setting the socket to non-blocking. This way we can detect when
there's nothing left to read and loop back to wait with epoll.
Fix modules starting with no text, but not hidding.
Start with some "text" in the module's label_, update() will then
update it. Since the text should be different, update() will be able
to show or hide the event_box_. This is to work around the case where
the module start with no text, but the the event_box_ is shown.
`format-discharging-full` has been impossible since #923 made it
impossible to be full and discharging at the same time. This should
fix that by only making `format-charging-full` impossible. Whether
or not that should be allowed is a good question, but beyond the
scope of this change.
Fixes#1031
std::regex and std::regex_replace may throw an std::regex_error if the
expression or replacement contain errors.
Log this error and carry on with the next rule, so that the title is
shown even if the config contains errors.
Rewrites window title according to config option "rewrite".
"rewrite" is an object where keys are regular expressions and values are
rewrite rules if the expression matches. Rules may contain references to
captures of the expression. Regex and replacement follow ECMA-script
rules. If no regex matches, the title is left unchanged.
example:
"sway/window": {
"rewrite": {
"(.*) - Mozilla Firefox": " $1",
"(.*) - zsh": " $1",
}
}
Allow the user to show the current volume from MPD status via the
`format` and/or `tooltip-format` configuration options.
The values are provided by libmpdclient and are integers, generally
between 0-100 (without %). Values above 100 are also possible, as mpd
output plugins like `pulse` support volumes above 100%.
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
On some systems (eg: ARM) the supported frequencies of the CPU are not
properly reported by /proc/cpuinfo so if that fails try to retrieve them
from /sys/devices/system/cpu/cpufreq/policy[0-9]/cpuinfo_[max|min]_freq.