Compare commits

..

9 Commits
0.1.1 ... 0.1.2

Author SHA1 Message Date
e8f3c1c6b3 chore: v0.1.2 2018-10-26 11:21:04 +02:00
7e6c701659 chore: update README 2018-10-26 11:16:17 +02:00
adc38c3dfe feat(sni): set protocol version 2018-10-26 10:56:45 +02:00
b10907ee44 refactor: remove useless code 2018-10-26 10:39:25 +02:00
0c9699b076 fix: check before set is host registered 2018-10-26 10:27:15 +02:00
63e86fbe9e fix: check type 2018-10-26 10:12:34 +02:00
f20441fa92 refactor: simpler sni naming 2018-10-26 10:05:54 +02:00
3f269ff463 fix: check json::value type 2018-10-26 09:27:16 +02:00
fd76e98552 fix: ifdef include 2018-10-25 19:12:28 +02:00
21 changed files with 87 additions and 92 deletions

View File

@ -7,6 +7,7 @@
**Current features**
- Sway Workspaces
- Sway focused window name
- Tray (Beta) [#21](https://github.com/Alexays/Waybar/issues/21)
- Local time
- Battery
- Network

View File

@ -9,7 +9,9 @@
#include "modules/battery.hpp"
#include "modules/memory.hpp"
#include "modules/cpu.hpp"
#ifdef HAVE_DBUSMENU
#include "modules/sni/tray.hpp"
#endif
#ifdef HAVE_LIBNL
#include "modules/network.hpp"
#endif

View File

@ -19,10 +19,8 @@ class Host {
static void nameVanished(GDBusConnection*, const gchar*, gpointer);
static void proxyReady(GObject*, GAsyncResult*, gpointer);
static void registerHost(GObject*, GAsyncResult*, gpointer);
static void itemRegistered(SnOrgKdeStatusNotifierWatcher*, const gchar*,
gpointer);
static void itemUnregistered(SnOrgKdeStatusNotifierWatcher*, const gchar*,
gpointer);
static void itemRegistered(SnWatcher*, const gchar*, gpointer);
static void itemUnregistered(SnWatcher*, const gchar*, gpointer);
std::tuple<std::string, std::string> getBusNameAndObjectPath(const gchar*);
void addRegisteredItem(const gchar* service);
@ -33,7 +31,7 @@ class Host {
std::string object_path_;
Glib::Dispatcher* dp_;
GCancellable* cancellable_ = nullptr;
SnOrgKdeStatusNotifierWatcher* watcher_ = nullptr;
SnWatcher* watcher_ = nullptr;
};
}

View File

@ -45,7 +45,7 @@ private:
Glib::Dispatcher *dp_;
GCancellable *cancellable_ = nullptr;
SnOrgKdeStatusNotifierItem *proxy_ = nullptr;
SnItem *proxy_ = nullptr;
};
} // namespace waybar::modules::SNI

View File

@ -34,13 +34,13 @@ private:
static void nameVanished(GDBusConnection *connection, const char *name,
gpointer data);
void updateRegisteredItems(SnOrgKdeStatusNotifierWatcher *obj);
void updateRegisteredItems(SnWatcher *obj);
uint32_t bus_name_id_;
uint32_t watcher_id_;
GSList *hosts_ = nullptr;
GSList *items_ = nullptr;
SnOrgKdeStatusNotifierWatcher *watcher_ = nullptr;
SnWatcher *watcher_ = nullptr;
};
} // namespace waybar::modules::SNI

View File

@ -1,6 +1,6 @@
project(
'waybar', 'cpp', 'c',
version: '0.1.0',
version: '0.1.2',
license: 'MIT',
default_options : [
'cpp_std=c++17',

View File

@ -2,6 +2,7 @@
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.StatusNotifierItem">
<annotation name="org.gtk.GDBus.C.Name" value="Item" />
<property name="Category" type="s" access="read"/>
<property name="Id" type="s" access="read"/>
<property name="Title" type="s" access="read"/>

View File

@ -1,24 +1,30 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.kde.StatusNotifierWatcher">
<annotation name="org.gtk.GDBus.C.Name" value="Watcher" />
<!-- methods -->
<method name="RegisterStatusNotifierItem">
<arg name="service" type="s" direction="in"/>
<annotation name="org.gtk.GDBus.C.Name" value="RegisterItem" />
<arg name="service" type="s" direction="in"/>
</method>
<method name="RegisterStatusNotifierHost">
<arg name="service" type="s" direction="in"/>
<annotation name="org.gtk.GDBus.C.Name" value="RegisterHost" />
<arg name="service" type="s" direction="in"/>
</method>
<!-- properties -->
<property name="RegisteredStatusNotifierItems" type="as" access="read">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QStringList"/>
<annotation name="org.gtk.GDBus.C.Name" value="RegisteredItems" />
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QStringList"/>
</property>
<property name="IsStatusNotifierHostRegistered" type="b" access="read"/>
<property name="IsStatusNotifierHostRegistered" type="b" access="read">
<annotation name="org.gtk.GDBus.C.Name" value="IsHostRegistered" />
</property>
<property name="ProtocolVersion" type="i" access="read"/>
@ -26,17 +32,21 @@
<!-- signals -->
<signal name="StatusNotifierItemRegistered">
<arg type="s"/>
<annotation name="org.gtk.GDBus.C.Name" value="ItemRegistered" />
<arg type="s" direction="out" name="service" />
</signal>
<signal name="StatusNotifierItemUnregistered">
<arg type="s"/>
<annotation name="org.gtk.GDBus.C.Name" value="ItemUnregistered" />
<arg type="s" direction="out" name="service" />
</signal>
<signal name="StatusNotifierHostRegistered">
<annotation name="org.gtk.GDBus.C.Name" value="HostRegistered" />
</signal>
<signal name="StatusNotifierHostUnregistered">
<annotation name="org.gtk.GDBus.C.Name" value="HostUnregistered" />
</signal>
</interface>
</node>

View File

@ -4,15 +4,15 @@
waybar::ALabel::ALabel(const Json::Value& config, const std::string format)
: config_(config),
format_(config_["format"] ? config_["format"].asString() : format),
format_(config_["format"].isString() ? config_["format"].asString() : format),
default_format_(format_)
{
event_box_.add(label_);
if (config_["max-length"]) {
if (config_["max-length"].isUInt()) {
label_.set_max_width_chars(config_["max-length"].asUInt());
label_.set_ellipsize(Pango::EllipsizeMode::ELLIPSIZE_END);
}
if (config_["format-alt"]) {
if (config_["format-alt"].isString()) {
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
event_box_.signal_button_press_event()
.connect(sigc::mem_fun(*this, &ALabel::handleToggle));
@ -40,7 +40,7 @@ std::string waybar::ALabel::getIcon(uint16_t percentage, const std::string& alt)
{
auto format_icons = config_["format-icons"];
if (format_icons.isObject()) {
if (!alt.empty() && format_icons[alt]) {
if (!alt.empty() && format_icons[alt].isString()) {
format_icons = format_icons[alt];
} else {
format_icons = format_icons["default"];

View File

@ -53,8 +53,8 @@ waybar::Bar::Bar(const Client& client,
anchor |= ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP;
}
auto height = config_["height"] ? config_["height"].asUInt() : height_;
auto width = config_["width"] ? config_["width"].asUInt() : width_;
auto height = config_["height"].isUInt() ? config_["height"].asUInt() : height_;
auto width = config_["width"].isUInt() ? config_["width"].asUInt() : width_;
zwlr_layer_surface_v1_set_anchor(layer_surface, anchor);
zwlr_layer_surface_v1_set_exclusive_zone(layer_surface, height);
zwlr_layer_surface_v1_set_size(layer_surface, width, height);
@ -163,7 +163,7 @@ auto waybar::Bar::setupCss() -> void
void waybar::Bar::getModules(const Factory& factory, const std::string& pos)
{
if (config_[pos]) {
if (config_[pos].isArray()) {
for (const auto &name : config_[pos]) {
try {
auto module = factory.makeModule(name.asString());

View File

@ -4,7 +4,7 @@ waybar::modules::Battery::Battery(const Json::Value& config)
: ALabel(config, "{capacity}%")
{
try {
if (config_["bat"]) {
if (config_["bat"].isString()) {
auto dir = data_dir_ / config_["bat"].asString();
if (fs::is_directory(dir) && fs::exists(dir / "capacity")
&& fs::exists(dir / "status") && fs::exists(dir / "uevent")) {
@ -22,7 +22,7 @@ waybar::modules::Battery::Battery(const Json::Value& config)
throw std::runtime_error(e.what());
}
if (batteries_.empty()) {
if (config_["bat"]) {
if (config_["bat"].isString()) {
throw std::runtime_error("No battery named " + config_["bat"].asString());
}
throw std::runtime_error("No batteries.");
@ -47,7 +47,7 @@ void waybar::modules::Battery::worker()
{
// Trigger first values
update();
uint32_t interval = config_["interval"] ? config_["interval"].asUInt() : 60;
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60;
threadTimer_ = [this, interval] {
thread_.sleep_for(chrono::seconds(interval));
dp.emit();
@ -88,7 +88,7 @@ auto waybar::modules::Battery::update() -> void
} else {
label_.get_style_context()->remove_class("charging");
}
auto critical = config_["critical"] ? config_["critical"].asUInt() : 15;
auto critical = config_["critical"].isUInt() ? config_["critical"].asUInt() : 15;
if (capacity <= critical && !charging) {
label_.get_style_context()->add_class("warning");
} else {

View File

@ -4,7 +4,7 @@ waybar::modules::Clock::Clock(const Json::Value& config)
: ALabel(config, "{:%H:%M}")
{
label_.set_name("clock");
uint32_t interval = config_["interval"] ? config_["interval"].asUInt() : 60;
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 60;
thread_ = [this, interval] {
auto now = waybar::chrono::clock::now();
dp.emit();

View File

@ -4,7 +4,7 @@ waybar::modules::Cpu::Cpu(const Json::Value& config)
: ALabel(config, "{}%")
{
label_.set_name("cpu");
uint32_t interval = config_["interval"] ? config_["interval"].asUInt() : 10;
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 10;
thread_ = [this, interval] {
dp.emit();
thread_.sleep_for(chrono::seconds(interval));

View File

@ -4,10 +4,10 @@ waybar::modules::Custom::Custom(const std::string name,
const Json::Value& config)
: ALabel(config, "{}"), name_(name)
{
if (!config_["exec"]) {
if (!config_["exec"].isString()) {
throw std::runtime_error(name_ + " has no exec path.");
}
if (config_["interval"]) {
if (config_["interval"].isUInt()) {
delayWorker();
} else {
continuousWorker();
@ -19,7 +19,7 @@ void waybar::modules::Custom::delayWorker()
auto interval = config_["interval"].asUInt();
thread_ = [this, interval] {
bool can_update = true;
if (config_["exec-if"]) {
if (config_["exec-if"].isString()) {
auto res = waybar::util::command::exec(config_["exec-if"].asString());
if (res.exit_code != 0) {
can_update = false;

View File

@ -4,7 +4,7 @@ waybar::modules::Memory::Memory(const Json::Value& config)
: ALabel(config, "{}%")
{
label_.set_name("memory");
uint32_t interval = config_["interval"] ? config_["interval"].asUInt() : 30;
uint32_t interval = config_["interval"].isUInt() ? config_["interval"].asUInt() : 30;
thread_ = [this, interval] {
dp.emit();
thread_.sleep_for(chrono::seconds(interval));

View File

@ -14,7 +14,7 @@ waybar::modules::Network::Network(const Json::Value& config)
sizeof(nladdr_)) != 0) {
throw std::runtime_error("Can't bind network socket");
}
if (config_["interface"]) {
if (config_["interface"].isString()) {
ifid_ = if_nametoindex(config_["interface"].asCString());
ifname_ = config_["interface"].asString();
if (ifid_ <= 0) {
@ -56,7 +56,7 @@ waybar::modules::Network::Network(const Json::Value& config)
}
}
}
if (ifid_ <= 0 && !config_["interface"]) {
if (ifid_ <= 0 && !config_["interface"].isString()) {
// Need to wait before get external interface
thread_.sleep_for(std::chrono::seconds(1));
ifid_ = getExternalInterface();
@ -84,15 +84,15 @@ auto waybar::modules::Network::update() -> void
{
auto format = format_;
if (ifid_ <= 0) {
format = config_["format-disconnected"]
format = config_["format-disconnected"].isString()
? config_["format-disconnected"].asString() : format;
label_.get_style_context()->add_class("disconnected");
} else {
if (essid_.empty()) {
format = config_["format-ethernet"]
format = config_["format-ethernet"].isString()
? config_["format-ethernet"].asString() : format;
} else {
format = config_["format-wifi"]
format = config_["format-wifi"].isString()
? config_["format-wifi"].asString() : format;
}
label_.get_style_context()->remove_class("disconnected");

View File

@ -131,10 +131,10 @@ auto waybar::modules::Pulseaudio::update() -> void
auto format = format_;
if (muted_) {
format =
config_["format-muted"] ? config_["format-muted"].asString() : format;
config_["format-muted"].isString() ? config_["format-muted"].asString() : format;
label_.get_style_context()->add_class("muted");
} else if (port_name_.find("a2dp_sink") != std::string::npos) {
format = config_["format-bluetooth"]
format = config_["format-bluetooth"].isString()
? config_["format-bluetooth"].asString() : format;
label_.get_style_context()->add_class("bluetooth");
} else {

View File

@ -35,7 +35,7 @@ void Host::nameAppeared(GDBusConnection* connection,
// TODO
}
host->cancellable_ = g_cancellable_new();
sn_org_kde_status_notifier_watcher_proxy_new(
sn_watcher_proxy_new(
connection,
G_DBUS_PROXY_FLAGS_NONE,
"org.kde.StatusNotifierWatcher",
@ -57,8 +57,7 @@ void Host::proxyReady(GObject* src, GAsyncResult* res,
gpointer data)
{
GError* error = nullptr;
SnOrgKdeStatusNotifierWatcher* watcher =
sn_org_kde_status_notifier_watcher_proxy_new_finish(res, &error);
SnWatcher* watcher = sn_watcher_proxy_new_finish(res, &error);
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
std::cerr << error->message << std::endl;
g_error_free(error);
@ -71,7 +70,7 @@ void Host::proxyReady(GObject* src, GAsyncResult* res,
g_error_free(error);
return;
}
sn_org_kde_status_notifier_watcher_call_register_status_notifier_host(
sn_watcher_call_register_host(
host->watcher_, host->object_path_.c_str(), host->cancellable_,
&Host::registerHost, data);
}
@ -80,8 +79,7 @@ void Host::registerHost(GObject* src, GAsyncResult* res,
gpointer data)
{
GError* error = nullptr;
sn_org_kde_status_notifier_watcher_call_register_status_notifier_host_finish(
SN_ORG_KDE_STATUS_NOTIFIER_WATCHER(src), res, &error);
sn_watcher_call_register_host_finish(SN_WATCHER(src), res, &error);
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
std::cerr << error->message << std::endl;
g_error_free(error);
@ -93,12 +91,11 @@ void Host::registerHost(GObject* src, GAsyncResult* res,
g_error_free(error);
return;
}
g_signal_connect(host->watcher_, "status-notifier-item-registered",
g_signal_connect(host->watcher_, "item-registered",
G_CALLBACK(&Host::itemRegistered), data);
g_signal_connect(host->watcher_, "status-notifier-item-unregistered",
g_signal_connect(host->watcher_, "item-unregistered",
G_CALLBACK(&Host::itemUnregistered), data);
auto items =
sn_org_kde_status_notifier_watcher_dup_registered_status_notifier_items(host->watcher_);
auto items = sn_watcher_dup_registered_items(host->watcher_);
if (items) {
for (uint32_t i = 0; items[i] != nullptr; i += 1) {
host->addRegisteredItem(items[i]);
@ -108,14 +105,14 @@ void Host::registerHost(GObject* src, GAsyncResult* res,
}
void Host::itemRegistered(
SnOrgKdeStatusNotifierWatcher* watcher, const gchar* service, gpointer data)
SnWatcher* watcher, const gchar* service, gpointer data)
{
auto host = static_cast<SNI::Host *>(data);
host->addRegisteredItem(service);
}
void Host::itemUnregistered(
SnOrgKdeStatusNotifierWatcher* watcher, const gchar* service, gpointer data)
SnWatcher* watcher, const gchar* service, gpointer data)
{
auto host = static_cast<SNI::Host *>(data);
auto [bus_name, object_path] = host->getBusNameAndObjectPath(service);

View File

@ -12,7 +12,7 @@ waybar::modules::SNI::Item::Item(std::string bn, std::string op,
event_box.signal_button_press_event().connect(
sigc::mem_fun(*this, &Item::handleClick));
cancellable_ = g_cancellable_new();
sn_org_kde_status_notifier_item_proxy_new_for_bus(
sn_item_proxy_new_for_bus(
G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, bus_name.c_str(),
object_path.c_str(), cancellable_, &Item::proxyReady, this);
}
@ -20,8 +20,8 @@ waybar::modules::SNI::Item::Item(std::string bn, std::string op,
void waybar::modules::SNI::Item::proxyReady(GObject *obj, GAsyncResult *res,
gpointer data) {
GError *error = nullptr;
SnOrgKdeStatusNotifierItem *proxy =
sn_org_kde_status_notifier_item_proxy_new_for_bus_finish(res, &error);
SnItem *proxy =
sn_item_proxy_new_for_bus_finish(res, &error);
if (g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
g_error_free(error);
return;
@ -227,7 +227,7 @@ waybar::modules::SNI::Item::getIconByName(std::string name, int request_size) {
void waybar::modules::SNI::Item::handleActivate(GObject *src, GAsyncResult *res,
gpointer data) {
auto item = static_cast<SNI::Item *>(data);
sn_org_kde_status_notifier_item_call_activate_finish(item->proxy_, res,
sn_item_call_activate_finish(item->proxy_, res,
nullptr);
}
@ -235,7 +235,7 @@ void waybar::modules::SNI::Item::handleSecondaryActivate(GObject *src,
GAsyncResult *res,
gpointer data) {
auto item = static_cast<SNI::Item *>(data);
sn_org_kde_status_notifier_item_call_secondary_activate_finish(item->proxy_,
sn_item_call_secondary_activate_finish(item->proxy_,
res, nullptr);
}
@ -247,11 +247,11 @@ bool waybar::modules::SNI::Item::handleClick(GdkEventButton *const &ev) {
}
gtk_menu->popup(ev->button, ev->time);
} else {
sn_org_kde_status_notifier_item_call_activate(
sn_item_call_activate(
proxy_, ev->x, ev->y, nullptr, &Item::handleActivate, this);
}
} else if (ev->type == GDK_2BUTTON_PRESS) {
sn_org_kde_status_notifier_item_call_secondary_activate(
sn_item_call_secondary_activate(
proxy_, ev->x, ev->y, nullptr, &Item::handleSecondaryActivate, this);
} else {
return false;

View File

@ -12,7 +12,8 @@ Watcher::Watcher()
bus_name_id_ = g_bus_own_name(G_BUS_TYPE_SESSION,
"org.kde.StatusNotifierWatcher", flags,
&Watcher::busAcquired, nullptr, nullptr, this, nullptr);
watcher_ = sn_org_kde_status_notifier_watcher_skeleton_new();
watcher_ = sn_watcher_skeleton_new();
sn_watcher_set_protocol_version(watcher_, 1);
}
Watcher::~Watcher()
@ -31,15 +32,10 @@ void Watcher::busAcquired(GDBusConnection* connection, const gchar* name,
g_error_free(error);
return;
}
g_signal_connect_swapped(host->watcher_,
"handle-register-status-notifier-item",
g_signal_connect_swapped(host->watcher_, "handle-register-item",
G_CALLBACK(&Watcher::handleRegisterItem), data);
g_signal_connect_swapped(host->watcher_,
"handle-register-status-notifier-host",
g_signal_connect_swapped(host->watcher_, "handle-register-host",
G_CALLBACK(&Watcher::handleRegisterHost), data);
sn_org_kde_status_notifier_watcher_set_protocol_version(host->watcher_, 0);
sn_org_kde_status_notifier_watcher_set_is_status_notifier_host_registered(
host->watcher_, TRUE);
}
gboolean Watcher::handleRegisterHost(Watcher* obj,
@ -66,14 +62,11 @@ gboolean Watcher::handleRegisterHost(Watcher* obj,
}
watch = gfWatchNew(GF_WATCH_TYPE_HOST, service, bus_name, object_path, obj);
obj->hosts_ = g_slist_prepend(obj->hosts_, watch);
sn_org_kde_status_notifier_watcher_set_is_status_notifier_host_registered(
obj->watcher_, TRUE);
if (g_slist_length(obj->hosts_)) {
sn_org_kde_status_notifier_watcher_emit_status_notifier_host_registered(
obj->watcher_);
if (!sn_watcher_get_is_host_registered(obj->watcher_)) {
sn_watcher_set_is_host_registered(obj->watcher_, TRUE);
sn_watcher_emit_host_registered(obj->watcher_);
}
sn_org_kde_status_notifier_watcher_complete_register_status_notifier_host(
obj->watcher_, invocation);
sn_watcher_complete_register_host(obj->watcher_, invocation);
return TRUE;
}
@ -96,19 +89,16 @@ gboolean Watcher::handleRegisterItem(Watcher* obj,
if (watch != nullptr) {
g_warning("Status Notifier Item with bus name '%s' and object path '%s' is already registered",
bus_name, object_path);
sn_org_kde_status_notifier_watcher_complete_register_status_notifier_item(
obj->watcher_, invocation);
sn_watcher_complete_register_item(obj->watcher_, invocation);
return TRUE;
}
watch = gfWatchNew(GF_WATCH_TYPE_ITEM, service, bus_name, object_path, obj);
obj->items_ = g_slist_prepend(obj->items_, watch);
obj->updateRegisteredItems(obj->watcher_);
gchar* tmp = g_strdup_printf("%s%s", bus_name, object_path);
sn_org_kde_status_notifier_watcher_emit_status_notifier_item_registered(
obj->watcher_, tmp);
sn_watcher_emit_item_registered(obj->watcher_, tmp);
g_free(tmp);
sn_org_kde_status_notifier_watcher_complete_register_status_notifier_item(
obj->watcher_, invocation);
sn_watcher_complete_register_item(obj->watcher_, invocation);
return TRUE;
}
@ -147,22 +137,19 @@ void Watcher::nameVanished(GDBusConnection* connection, const char* name,
if (watch->type == GF_WATCH_TYPE_HOST) {
watch->watcher->hosts_ = g_slist_remove(watch->watcher->hosts_, watch);
if (watch->watcher->hosts_ == nullptr) {
sn_org_kde_status_notifier_watcher_set_is_status_notifier_host_registered(
watch->watcher->watcher_, FALSE);
sn_org_kde_status_notifier_watcher_emit_status_notifier_host_registered(
watch->watcher->watcher_);
sn_watcher_set_is_host_registered(watch->watcher->watcher_, FALSE);
sn_watcher_emit_host_registered(watch->watcher->watcher_);
}
} else if (watch->type == GF_WATCH_TYPE_ITEM) {
watch->watcher->items_ = g_slist_remove(watch->watcher->items_, watch);
watch->watcher->updateRegisteredItems(watch->watcher->watcher_);
gchar* tmp = g_strdup_printf("%s%s", watch->bus_name, watch->object_path);
sn_org_kde_status_notifier_watcher_emit_status_notifier_item_unregistered(
watch->watcher->watcher_, tmp);
sn_watcher_emit_item_unregistered(watch->watcher->watcher_, tmp);
g_free(tmp);
}
}
void Watcher::updateRegisteredItems(SnOrgKdeStatusNotifierWatcher* obj)
void Watcher::updateRegisteredItems(SnWatcher* obj)
{
GVariantBuilder builder;
g_variant_builder_init(&builder, G_VARIANT_TYPE("as"));
@ -174,8 +161,7 @@ void Watcher::updateRegisteredItems(SnOrgKdeStatusNotifierWatcher* obj)
}
GVariant* variant = g_variant_builder_end(&builder);
const gchar** items = g_variant_get_strv(variant, nullptr);
sn_org_kde_status_notifier_watcher_set_registered_status_notifier_items(
obj, items);
sn_watcher_set_registered_items(obj, items);
g_variant_unref(variant);
g_free(items);
}

View File

@ -79,7 +79,7 @@ auto waybar::modules::sway::Workspaces::update() -> void
box_.reorder_child(button, node["num"].asInt());
}
auto icon = getIcon(node["name"].asString(), node);
if (config_["format"]) {
if (config_["format"].isString()) {
auto format = config_["format"].asString();
button.set_label(fmt::format(format, fmt::arg("icon", icon),
fmt::arg("name", node["name"].asString()),
@ -98,7 +98,7 @@ auto waybar::modules::sway::Workspaces::update() -> void
void waybar::modules::sway::Workspaces::addWorkspace(Json::Value node)
{
auto icon = getIcon(node["name"].asString(), node);
auto format = config_["format"]
auto format = config_["format"].isString()
? fmt::format(config_["format"].asString(), fmt::arg("icon", icon),
fmt::arg("name", node["name"].asString()),
fmt::arg("index", node["num"].asString()))
@ -141,10 +141,10 @@ std::string waybar::modules::sway::Workspaces::getIcon(std::string name,
name, "urgent", "focused", "visible", "default"};
for (auto const& key : keys) {
if (key == "focused" || key == "visible" || key == "urgent") {
if (config_["format-icons"][key] && node[key].asBool()) {
if (config_["format-icons"][key].isString() && node[key].asBool()) {
return config_["format-icons"][key].asString();
}
} else if (config_["format-icons"][key]) {
} else if (config_["format-icons"][key].isString()) {
return config_["format-icons"][key].asString();
}
}