Compare commits

...

18 Commits

Author SHA1 Message Date
Alexis Rouillard
71b01fe58f
Merge pull request #4161 from blackxored/feat/electron-tray-hack
feat: add a way to override electron app tray icons
2025-07-20 18:55:01 +02:00
Alexis Rouillard
2baa93174b
Merge pull request #4260 from notpeelz/feat-display-rfkill-setting
feat: add rfkill network setting
2025-07-20 18:54:24 +02:00
Alexis Rouillard
321ed85a67
Merge pull request #4298 from csskevin/docu-arch
adding dependency command for arch
2025-07-20 18:51:57 +02:00
Alexis Rouillard
e526afb963
Merge pull request #4310 from arnaud-ma/remove-persistent-workspace-rules
Fix #4307
2025-07-20 18:51:01 +02:00
arnaud-ma
8dcdd97879
small fixes 2025-07-19 05:01:29 +02:00
arnaud-ma
2dc2b5ccfd
fix #4307 2025-07-19 04:50:59 +02:00
arnaud-ma
a4f200cdb5
revert 2025-07-19 04:47:31 +02:00
arnaud-ma
64ed2cd970
fix indentation 2025-07-19 03:23:32 +02:00
arnaud-ma
e45883088d
hyprland: Remove redundant workspace rules loading 2025-07-19 03:18:48 +02:00
csskevin
061c561762 adding dependency command for arch 2025-07-15 00:19:55 +02:00
peelz
73d9c5f560 fix(network): reset is_p2p_ in clearIface 2025-07-10 08:01:20 -04:00
peelz
b85f0c17c3 fix(network): ignore carrier state when the interface is down
I'm not sure why, but my network card (mt7921e) sometimes will report
having a carrier when the interface is down. This usually happens
when rfkill was active before rebooting.
2025-07-10 08:01:20 -04:00
peelz
b02694caef fix(network): initialize all fields
Some fields were previously uninitialized (e.g. carrier), which
could lead to UB.
2025-07-10 08:01:20 -04:00
peelz
2dfbaabf31 fix(network): use atomic_bool to store the rfkill state 2025-07-10 08:01:20 -04:00
peelz
f991af2893 style(network): fix trailing white space 2025-07-10 08:01:20 -04:00
peelz
0e07c7ac5c feat(network): add rfkill setting
This setting makes it possible to have a configuration with two
network modules where one of them displays the ethernet state
(disconnected, linked, ethernet), and the other, the wifi state
(disabled, disconnected, linked, wifi).

Otherwise the ethernet state would show up as "disabled" (instead of
"disconnected") when rfkill is active.
2025-07-10 08:01:20 -04:00
peelz
46a152abc8 fix(network): display as disabled if rfkill and no carrier
We want the "disabled" state even when an interface is selected
explicitly.
2025-07-10 08:01:20 -04:00
Adrian Perez
81fb0daad2
feat: add a way to override electron app tray icons 2025-06-03 16:13:41 -07:00
7 changed files with 107 additions and 51 deletions

View File

@ -116,6 +116,36 @@ sudo apt install \
libxkbregistry-dev
```
On Arch, you can use this command:
```
pacman -S \
gtkmm3 \
jsoncpp \
libsigc++ \
fmt \
wayland \
chrono-date \
spdlog \
gtk3 \
gobject-introspection \
libgirepository \
libpulse \
libnl \
libappindicator-gtk3 \
libdbusmenu-gtk3 \
libmpdclient \
sndio \
libevdev \
libxkbcommon \
upower \
meson \
cmake \
scdoc \
wayland-protocols \
glib2-devel
```
Contributions welcome!<br>
Have fun :)<br>

View File

@ -27,8 +27,8 @@ class Network : public ALabel {
auto update() -> void override;
private:
static const uint8_t MAX_RETRY = 5;
static const uint8_t EPOLL_MAX = 200;
static const uint8_t MAX_RETRY{5};
static const uint8_t EPOLL_MAX{200};
static int handleEvents(struct nl_msg*, void*);
static int handleEventsDone(struct nl_msg*, void*);
@ -51,37 +51,37 @@ class Network : public ALabel {
bool wildcardMatch(const std::string& pattern, const std::string& text) const;
std::optional<std::pair<unsigned long long, unsigned long long>> readBandwidthUsage();
int ifid_;
ip_addr_pref addr_pref_;
struct sockaddr_nl nladdr_ = {0};
struct nl_sock* sock_ = nullptr;
struct nl_sock* ev_sock_ = nullptr;
int efd_;
int ev_fd_;
int nl80211_id_;
int ifid_{-1};
ip_addr_pref addr_pref_{ip_addr_pref::IPV4};
struct sockaddr_nl nladdr_{0};
struct nl_sock* sock_{nullptr};
struct nl_sock* ev_sock_{nullptr};
int efd_{-1};
int ev_fd_{-1};
int nl80211_id_{-1};
std::mutex mutex_;
bool want_route_dump_;
bool want_link_dump_;
bool want_addr_dump_;
bool dump_in_progress_;
bool is_p2p_;
bool want_route_dump_{false};
bool want_link_dump_{false};
bool want_addr_dump_{false};
bool dump_in_progress_{false};
bool is_p2p_{false};
unsigned long long bandwidth_down_total_;
unsigned long long bandwidth_up_total_;
unsigned long long bandwidth_down_total_{0};
unsigned long long bandwidth_up_total_{0};
std::string state_;
std::string essid_;
std::string bssid_;
bool carrier_;
bool carrier_{false};
std::string ifname_;
std::string ipaddr_;
std::string ipaddr6_;
std::string gwaddr_;
std::string netmask_;
std::string netmask6_;
int cidr_;
int cidr6_;
int cidr_{0};
int cidr6_{0};
int32_t signal_strength_dbm_;
uint8_t signal_strength_;
std::string signal_strength_app_;
@ -90,9 +90,9 @@ class Network : public ALabel {
util::SleeperThread thread_;
util::SleeperThread thread_timer_;
#ifdef WANT_RFKILL
util::Rfkill rfkill_;
util::Rfkill rfkill_{RFKILL_TYPE_WLAN};
#endif
float frequency_;
float frequency_{0};
};
} // namespace waybar::modules

View File

@ -5,6 +5,8 @@
#include <sigc++/signal.h>
#include <sigc++/trackable.h>
#include <atomic>
namespace waybar::util {
class Rfkill : public sigc::trackable {
@ -17,7 +19,7 @@ class Rfkill : public sigc::trackable {
private:
enum rfkill_type rfkill_type_;
bool state_ = false;
std::atomic_bool state_ = false;
int fd_ = -1;
bool on_event(Glib::IOCondition cond);

View File

@ -16,6 +16,11 @@ Addressed by *network*
typeof: string ++
Use the defined interface instead of auto-detection. Accepts wildcard.
*rfkill*: ++
typeof: bool ++
default: true ++
If enabled, the *disabled* format will be used when rfkill is blocking wlan interfaces.
*interval*: ++
typeof: integer ++
default: 60 ++
@ -49,7 +54,7 @@ Addressed by *network*
*format-disabled*: ++
typeof: string ++
This format is used when the displayed interface is disabled.
This format is used when rfkill is blocking wlan interfaces.
*format-icons*: ++
typeof: array/object ++
@ -127,7 +132,7 @@ Addressed by *network*
*tooltip-format-disabled*: ++
typeof: string ++
This format is used when the displayed interface is disabled.
This format is used when rfkill is blocking wlan interfaces.
*menu*: ++
typeof: string ++
@ -157,7 +162,7 @@ Addressed by *network*
*{netmask}*: The subnetmask corresponding to the IP(V4).
*{netmask6}*: The subnetmask corresponding to the IP(V6).
*{netmask6}*: The subnetmask corresponding to the IP(V6).
*{cidr}*: The subnetmask corresponding to the IP(V4) in CIDR notation.

View File

@ -294,8 +294,13 @@ void Workspaces::loadPersistentWorkspacesFromWorkspaceRules(const Json::Value &c
if (!rule["persistent"].asBool()) {
continue;
}
auto const &workspace = rule.isMember("defaultName") ? rule["defaultName"].asString()
auto workspace = rule.isMember("defaultName") ? rule["defaultName"].asString()
: rule["workspaceString"].asString();
// The prefix "name:" cause mismatches with workspace names taken anywhere else.
if (workspace.starts_with("name:")) {
workspace = workspace.substr(5);
}
auto const &monitor = rule["monitor"].asString();
// create this workspace persistently if:
// 1. the allOutputs config option is enabled
@ -1034,4 +1039,4 @@ std::optional<int> Workspaces::parseWorkspaceId(std::string const &workspaceIdSt
}
}
} // namespace waybar::modules::hyprland
} // namespace waybar::modules::hyprland

View File

@ -78,25 +78,7 @@ waybar::modules::Network::readBandwidthUsage() {
}
waybar::modules::Network::Network(const std::string &id, const Json::Value &config)
: ALabel(config, "network", id, DEFAULT_FORMAT, 60),
ifid_(-1),
addr_pref_(IPV4),
efd_(-1),
ev_fd_(-1),
want_route_dump_(false),
want_link_dump_(false),
want_addr_dump_(false),
dump_in_progress_(false),
is_p2p_(false),
cidr_(0),
cidr6_(0),
signal_strength_dbm_(0),
signal_strength_(0),
#ifdef WANT_RFKILL
rfkill_{RFKILL_TYPE_WLAN},
#endif
frequency_(0.0) {
: ALabel(config, "network", id, DEFAULT_FORMAT, 60) {
// 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
@ -271,11 +253,16 @@ void waybar::modules::Network::worker() {
}
const std::string waybar::modules::Network::getNetworkState() const {
if (ifid_ == -1 || !carrier_) {
#ifdef WANT_RFKILL
if (rfkill_.getState() && ifid_ == -1) return "disabled";
bool display_rfkill = true;
if (config_["rfkill"].isBool()) {
display_rfkill = config_["rfkill"].asBool();
}
if (rfkill_.getState() && display_rfkill) return "disabled";
#endif
if (ifid_ == -1) return "disconnected";
if (!carrier_) return "disconnected";
return "disconnected";
}
if (ipaddr_.empty() && ipaddr6_.empty()) return "linked";
if (essid_.empty()) return "ethernet";
return "wifi";
@ -418,6 +405,7 @@ void waybar::modules::Network::clearIface() {
netmask_.clear();
netmask6_.clear();
carrier_ = false;
is_p2p_ = false;
cidr_ = 0;
cidr6_ = 0;
signal_strength_dbm_ = 0;
@ -507,6 +495,11 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
net->ifname_ = new_ifname;
net->ifid_ = ifi->ifi_index;
if (ifi->ifi_flags & IFF_POINTOPOINT) net->is_p2p_ = true;
if ((ifi->ifi_flags & IFF_UP) == 0) {
// With some network drivers (e.g. mt7921e), the interface may
// report having a carrier even though interface is down.
carrier = false;
}
if (carrier.has_value()) {
net->carrier_ = carrier.value();
}

View File

@ -1,3 +1,4 @@
#include <spdlog/spdlog.h>
#include "modules/sni/item.hpp"
#include <gdkmm/general.h>
@ -140,7 +141,25 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
category = get_variant<std::string>(value);
} else if (name == "Id") {
id = get_variant<std::string>(value);
setCustomIcon(id);
/*
* HACK: Electron apps seem to have the same ID, but tooltip seems correct, so use that as ID
* to pass as the custom icon option. I'm avoiding being disruptive and setting that to the ID
* itself as I've no idea what this would affect.
* The tooltip text is converted to lowercase since that's what (most?) themes expect?
* I still haven't found a way for it to pick from theme automatically, although
* it might be my theme.
*/
if (id == "chrome_status_icon_1") {
Glib::VariantBase value;
this->proxy_->get_cached_property(value, "ToolTip");
tooltip = get_variant<ToolTip>(value);
if (!tooltip.text.empty()) {
setCustomIcon(tooltip.text.lowercase());
}
} else {
setCustomIcon(id);
}
} else if (name == "Title") {
title = get_variant<std::string>(value);
if (tooltip.text.empty()) {
@ -203,6 +222,8 @@ void Item::setStatus(const Glib::ustring& value) {
}
void Item::setCustomIcon(const std::string& id) {
spdlog::debug("SNI tray id: {}", id);
std::string custom_icon = IconManager::instance().getIconForApp(id);
if (!custom_icon.empty()) {
if (std::filesystem::exists(custom_icon)) {