Skip to content

Commit

Permalink
Merge branch 'Alexays:master' into hyprland/windowcount
Browse files Browse the repository at this point in the history
  • Loading branch information
nktnet1 authored Dec 22, 2024
2 parents 334fc6e + e959f1d commit d29a17d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 36 deletions.
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion include/modules/network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ class Network : public ALabel {
std::optional<std::pair<unsigned long long, unsigned long long>> readBandwidthUsage();

int ifid_;
sa_family_t family_;
struct sockaddr_nl nladdr_ = {0};
struct nl_sock* sock_ = nullptr;
struct nl_sock* ev_sock_ = nullptr;
Expand Down
1 change: 1 addition & 0 deletions man/waybar-sway-workspaces.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ warp-on-scroll: ++
Keys are the rules, while the values are the methods of representation.
Rules may specify `class<...>`, `title<...>`, or both in order to fine-tune the matching.
You may assign an empty value to a rule to have it ignored from generating any representation in workspaces.
For Wayland windows `class` is matched against the `app_id`, and for X11 windows against the `class` property.

*window-rewrite-default*:
typeof: string ++
Expand Down
34 changes: 7 additions & 27 deletions src/modules/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ 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),
family_(config["family"] == "ipv6" ? AF_INET6 : AF_INET),
efd_(-1),
ev_fd_(-1),
want_route_dump_(false),
Expand Down Expand Up @@ -141,12 +140,7 @@ waybar::modules::Network::~Network() {
close(efd_);
}
if (ev_sock_ != nullptr) {
nl_socket_drop_membership(ev_sock_, RTNLGRP_LINK);
if (family_ == AF_INET) {
nl_socket_drop_membership(ev_sock_, RTNLGRP_IPV4_IFADDR);
} else {
nl_socket_drop_membership(ev_sock_, RTNLGRP_IPV6_IFADDR);
}
nl_socket_drop_memberships(ev_sock_, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR);
nl_close(ev_sock_);
nl_socket_free(ev_sock_);
}
Expand All @@ -161,26 +155,17 @@ void waybar::modules::Network::createEventSocket() {
nl_socket_disable_seq_check(ev_sock_);
nl_socket_modify_cb(ev_sock_, NL_CB_VALID, NL_CB_CUSTOM, handleEvents, this);
nl_socket_modify_cb(ev_sock_, NL_CB_FINISH, NL_CB_CUSTOM, handleEventsDone, this);
auto groups = RTMGRP_LINK | (family_ == AF_INET ? RTMGRP_IPV4_IFADDR : RTMGRP_IPV6_IFADDR);
auto groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
nl_join_groups(ev_sock_, groups); // Deprecated
if (nl_connect(ev_sock_, NETLINK_ROUTE) != 0) {
throw std::runtime_error("Can't connect network socket");
}
if (nl_socket_set_nonblocking(ev_sock_)) {
throw std::runtime_error("Can't set non-blocking on network socket");
}
nl_socket_add_membership(ev_sock_, RTNLGRP_LINK);
if (family_ == AF_INET) {
nl_socket_add_membership(ev_sock_, RTNLGRP_IPV4_IFADDR);
} else {
nl_socket_add_membership(ev_sock_, RTNLGRP_IPV6_IFADDR);
}
nl_socket_add_memberships(ev_sock_, RTNLGRP_LINK, RTNLGRP_IPV4_IFADDR, RTNLGRP_IPV6_IFADDR, 0);
if (!config_["interface"].isString()) {
if (family_ == AF_INET) {
nl_socket_add_membership(ev_sock_, RTNLGRP_IPV4_ROUTE);
} else {
nl_socket_add_membership(ev_sock_, RTNLGRP_IPV6_ROUTE);
}
nl_socket_add_memberships(ev_sock_, RTNLGRP_IPV4_ROUTE, RTNLGRP_IPV6_ROUTE, 0);
}

efd_ = epoll_create1(EPOLL_CLOEXEC);
Expand Down Expand Up @@ -531,10 +516,6 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
return NL_OK;
}

if (ifa->ifa_family != net->family_) {
return NL_OK;
}

// We ignore address mark as scope for the link or host,
// which should leave scope global addresses.
if (ifa->ifa_scope >= RT_SCOPE_LINK) {
Expand Down Expand Up @@ -591,6 +572,7 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
// to find the interface used to reach the outside world

struct rtmsg *rtm = static_cast<struct rtmsg *>(NLMSG_DATA(nh));
int family = rtm->rtm_family;
ssize_t attrlen = RTM_PAYLOAD(nh);
struct rtattr *attr = RTM_RTA(rtm);
bool has_gateway = false;
Expand Down Expand Up @@ -618,14 +600,14 @@ int waybar::modules::Network::handleEvents(struct nl_msg *msg, void *data) {
* If someone ever needs to figure out the gateway address as well,
* it's here as the attribute payload.
*/
inet_ntop(net->family_, RTA_DATA(attr), temp_gw_addr, sizeof(temp_gw_addr));
inet_ntop(family, RTA_DATA(attr), temp_gw_addr, sizeof(temp_gw_addr));
has_gateway = true;
break;
case RTA_DST: {
/* The destination address.
* Should be either missing, or maybe all 0s. Accept both.
*/
const uint32_t nr_zeroes = (net->family_ == AF_INET) ? 4 : 16;
const uint32_t nr_zeroes = (family == AF_INET) ? 4 : 16;
unsigned char c = 0;
size_t dstlen = RTA_PAYLOAD(attr);
if (dstlen != nr_zeroes) {
Expand Down Expand Up @@ -717,7 +699,6 @@ void waybar::modules::Network::askForStateDump(void) {
};

if (want_route_dump_) {
rt_hdr.rtgen_family = family_;
nl_send_simple(ev_sock_, RTM_GETROUTE, NLM_F_DUMP, &rt_hdr, sizeof(rt_hdr));
want_route_dump_ = false;
dump_in_progress_ = true;
Expand All @@ -728,7 +709,6 @@ void waybar::modules::Network::askForStateDump(void) {
dump_in_progress_ = true;

} else if (want_addr_dump_) {
rt_hdr.rtgen_family = family_;
nl_send_simple(ev_sock_, RTM_GETADDR, NLM_F_DUMP, &rt_hdr, sizeof(rt_hdr));
want_addr_dump_ = false;
dump_in_progress_ = true;
Expand Down
4 changes: 3 additions & 1 deletion src/modules/sway/workspaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ void Workspaces::updateWindows(const Json::Value &node, std::string &windows) {
if ((node["type"].asString() == "con" || node["type"].asString() == "floating_con") &&
node["name"].isString()) {
std::string title = g_markup_escape_text(node["name"].asString().c_str(), -1);
std::string windowClass = node["app_id"].asString();
std::string windowClass = node["app_id"].isString()
? node["app_id"].asString()
: node["window_properties"]["class"].asString();

// Only add window rewrites that can be looked up
if (!windowClass.empty()) {
Expand Down
12 changes: 12 additions & 0 deletions src/util/audio_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ void AudioBackend::changeVolume(uint16_t volume, uint16_t min_volume, uint16_t m
volume = std::clamp(volume, min_volume, max_volume);
pa_cvolume_set(&pa_volume, pa_volume_.channels, volume * volume_tick);

pa_threaded_mainloop_lock(mainloop_);
pa_context_set_sink_volume_by_index(context_, sink_idx_, &pa_volume, volumeModifyCb, this);
pa_threaded_mainloop_unlock(mainloop_);
}

void AudioBackend::changeVolume(ChangeType change_type, double step, uint16_t max_volume) {
Expand Down Expand Up @@ -265,31 +267,41 @@ void AudioBackend::changeVolume(ChangeType change_type, double step, uint16_t ma
pa_cvolume_dec(&pa_volume, change);
}
}
pa_threaded_mainloop_lock(mainloop_);
pa_context_set_sink_volume_by_index(context_, sink_idx_, &pa_volume, volumeModifyCb, this);
pa_threaded_mainloop_unlock(mainloop_);
}

void AudioBackend::toggleSinkMute() {
muted_ = !muted_;
pa_threaded_mainloop_lock(mainloop_);
pa_context_set_sink_mute_by_index(context_, sink_idx_, static_cast<int>(muted_), nullptr,
nullptr);
pa_threaded_mainloop_unlock(mainloop_);
}

void AudioBackend::toggleSinkMute(bool mute) {
muted_ = mute;
pa_threaded_mainloop_lock(mainloop_);
pa_context_set_sink_mute_by_index(context_, sink_idx_, static_cast<int>(muted_), nullptr,
nullptr);
pa_threaded_mainloop_unlock(mainloop_);
}

void AudioBackend::toggleSourceMute() {
source_muted_ = !muted_;
pa_threaded_mainloop_lock(mainloop_);
pa_context_set_source_mute_by_index(context_, source_idx_, static_cast<int>(source_muted_),
nullptr, nullptr);
pa_threaded_mainloop_unlock(mainloop_);
}

void AudioBackend::toggleSourceMute(bool mute) {
source_muted_ = mute;
pa_threaded_mainloop_lock(mainloop_);
pa_context_set_source_mute_by_index(context_, source_idx_, static_cast<int>(source_muted_),
nullptr, nullptr);
pa_threaded_mainloop_unlock(mainloop_);
}

bool AudioBackend::isBluetooth() {
Expand Down
8 changes: 7 additions & 1 deletion src/util/backlight_backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,13 @@ BacklightBackend::BacklightBackend(std::chrono::milliseconds interval,
// Connect to the login interface
login_proxy_ = Gio::DBus::Proxy::create_for_bus_sync(
Gio::DBus::BusType::BUS_TYPE_SYSTEM, "org.freedesktop.login1",
"/org/freedesktop/login1/session/self", "org.freedesktop.login1.Session");
"/org/freedesktop/login1/session/auto", "org.freedesktop.login1.Session");

if (!login_proxy_) {
login_proxy_ = Gio::DBus::Proxy::create_for_bus_sync(
Gio::DBus::BusType::BUS_TYPE_SYSTEM, "org.freedesktop.login1",
"/org/freedesktop/login1/session/self", "org.freedesktop.login1.Session");
}

udev_thread_ = [this] {
std::unique_ptr<udev, UdevDeleter> udev{udev_new()};
Expand Down

0 comments on commit d29a17d

Please sign in to comment.