Merge branch 'master' into master
commit
1974766125
|
@ -28,9 +28,8 @@ protected:
|
|||
bool alt_ = false;
|
||||
std::string default_format_;
|
||||
|
||||
private:
|
||||
bool handleToggle(GdkEventButton *const &ev);
|
||||
bool handleScroll(GdkEventScroll *);
|
||||
virtual bool handleToggle(GdkEventButton *const &ev);
|
||||
virtual bool handleScroll(GdkEventScroll *);
|
||||
};
|
||||
|
||||
} // namespace waybar
|
||||
|
|
|
@ -13,7 +13,7 @@ class IdleInhibitor: public ALabel {
|
|||
~IdleInhibitor();
|
||||
auto update() -> void;
|
||||
private:
|
||||
bool onClick(GdkEventButton* const& ev);
|
||||
bool handleToggle(GdkEventButton* const& e);
|
||||
|
||||
const Bar& bar_;
|
||||
std::string status_;
|
||||
|
|
|
@ -20,6 +20,7 @@ class Workspaces : public IModule {
|
|||
private:
|
||||
void worker();
|
||||
void addWorkspace(const Json::Value&);
|
||||
void onButtonReady(const Json::Value&, Gtk::Button&);
|
||||
std::string getIcon(const std::string&, const Json::Value&);
|
||||
bool handleScroll(GdkEventScroll*);
|
||||
std::string getPrevWorkspace();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "modules/idle_inhibitor.hpp"
|
||||
|
||||
#include "util/command.hpp"
|
||||
|
||||
waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar& bar, const Json::Value& config)
|
||||
: ALabel(config, "{status}"), bar_(bar), status_("deactivated"), idle_inhibitor_(nullptr)
|
||||
|
@ -10,7 +10,7 @@ waybar::modules::IdleInhibitor::IdleInhibitor(const std::string& id, const Bar&
|
|||
}
|
||||
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
||||
event_box_.signal_button_press_event().connect(
|
||||
sigc::mem_fun(*this, &IdleInhibitor::onClick));
|
||||
sigc::mem_fun(*this, &IdleInhibitor::handleToggle));
|
||||
dp.emit();
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,8 @@ auto waybar::modules::IdleInhibitor::update() -> void
|
|||
}
|
||||
}
|
||||
|
||||
bool waybar::modules::IdleInhibitor::onClick(GdkEventButton* const& e)
|
||||
{
|
||||
if(e->button == 1) {
|
||||
bool waybar::modules::IdleInhibitor::handleToggle(GdkEventButton* const& e) {
|
||||
if (e->button == 1) {
|
||||
if (idle_inhibitor_) {
|
||||
zwp_idle_inhibitor_v1_destroy(idle_inhibitor_);
|
||||
idle_inhibitor_ = nullptr;
|
||||
|
@ -44,7 +43,13 @@ bool waybar::modules::IdleInhibitor::onClick(GdkEventButton* const& e)
|
|||
bar_.client.idle_inhibit_manager, bar_.surface);
|
||||
status_ = "activated";
|
||||
}
|
||||
if (config_["on-click"].isString() && e->button == 1) {
|
||||
waybar::util::command::forkExec(config_["on-click"].asString());
|
||||
}
|
||||
} else {
|
||||
ALabel::handleToggle(e);
|
||||
}
|
||||
|
||||
dp.emit();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@ void waybar::modules::Network::createInfoSocket()
|
|||
{
|
||||
info_sock_ = nl_socket_alloc();
|
||||
if (nl_connect(info_sock_, NETLINK_ROUTE) != 0) {
|
||||
throw std::runtime_error("Can't connect network socket");
|
||||
}
|
||||
throw std::runtime_error("Can't connect network socket");
|
||||
}
|
||||
if (nl_socket_add_membership(info_sock_, RTMGRP_LINK) != 0) {
|
||||
throw std::runtime_error("Can't add membership");
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void waybar::modules::Network::createInfoSocket()
|
|||
void waybar::modules::Network::createEventSocket()
|
||||
{
|
||||
sk_ = nl_socket_alloc();
|
||||
if (genl_connect(sk_) != 0) {
|
||||
if (genl_connect(sk_) != 0) {
|
||||
throw std::runtime_error("Can't connect to netlink socket");
|
||||
}
|
||||
if (nl_socket_modify_cb(sk_, NL_CB_VALID, NL_CB_CUSTOM, handleScan, this) < 0) {
|
||||
|
@ -135,10 +135,17 @@ void waybar::modules::Network::worker()
|
|||
auto waybar::modules::Network::update() -> void
|
||||
{
|
||||
std::string connectiontype;
|
||||
std::string tooltip_format = "";
|
||||
if (config_["tooltip-format"].isString()) {
|
||||
tooltip_format = config_["tooltip-format"].asString();
|
||||
}
|
||||
if (ifid_ <= 0 || ipaddr_.empty()) {
|
||||
if (config_["format-disconnected"].isString()) {
|
||||
default_format_ = config_["format-disconnected"].asString();
|
||||
}
|
||||
if (config_["tooltip-format-disconnected"].isString()) {
|
||||
tooltip_format = config_["tooltip-format-disconnected"].asString();
|
||||
}
|
||||
label_.get_style_context()->add_class("disconnected");
|
||||
connectiontype = "disconnected";
|
||||
} else {
|
||||
|
@ -146,11 +153,17 @@ auto waybar::modules::Network::update() -> void
|
|||
if (config_["format-ethernet"].isString()) {
|
||||
default_format_ = config_["format-ethernet"].asString();
|
||||
}
|
||||
if (config_["tooltip-format-ethernet"].isString()) {
|
||||
tooltip_format = config_["tooltip-format-ethernet"].asString();
|
||||
}
|
||||
connectiontype = "ethernet";
|
||||
} else {
|
||||
if (config_["format-wifi"].isString()) {
|
||||
default_format_ = config_["format-wifi"].asString();
|
||||
}
|
||||
if (config_["tooltip-format-wifi"].isString()) {
|
||||
tooltip_format = config_["tooltip-format-wifi"].asString();
|
||||
}
|
||||
connectiontype = "wifi";
|
||||
}
|
||||
label_.get_style_context()->remove_class("disconnected");
|
||||
|
@ -158,7 +171,7 @@ auto waybar::modules::Network::update() -> void
|
|||
if (!alt_) {
|
||||
format_ = default_format_;
|
||||
}
|
||||
label_.set_markup(fmt::format(format_,
|
||||
auto text = fmt::format(format_,
|
||||
fmt::arg("essid", essid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_),
|
||||
fmt::arg("signalStrength", signal_strength_),
|
||||
|
@ -167,7 +180,25 @@ auto waybar::modules::Network::update() -> void
|
|||
fmt::arg("ipaddr", ipaddr_),
|
||||
fmt::arg("cidr", cidr_),
|
||||
fmt::arg("icon", getIcon(signal_strength_, connectiontype))
|
||||
));
|
||||
);
|
||||
label_.set_markup(text);
|
||||
if (tooltipEnabled()) {
|
||||
if (!tooltip_format.empty()) {
|
||||
auto tooltip_text = fmt::format(tooltip_format,
|
||||
fmt::arg("essid", essid_),
|
||||
fmt::arg("signaldBm", signal_strength_dbm_),
|
||||
fmt::arg("signalStrength", signal_strength_),
|
||||
fmt::arg("ifname", ifname_),
|
||||
fmt::arg("netmask", netmask_),
|
||||
fmt::arg("ipaddr", ipaddr_),
|
||||
fmt::arg("cidr", cidr_),
|
||||
fmt::arg("icon", getIcon(signal_strength_, connectiontype))
|
||||
);
|
||||
label_.set_tooltip_text(tooltip_text);
|
||||
} else {
|
||||
label_.set_tooltip_text(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::modules::Network::disconnected()
|
||||
|
|
|
@ -87,7 +87,8 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
|||
} else {
|
||||
button.set_label(icon);
|
||||
}
|
||||
button.show();
|
||||
|
||||
onButtonReady(node, button);
|
||||
}
|
||||
}
|
||||
if (scrolling_) {
|
||||
|
@ -131,7 +132,8 @@ void waybar::modules::sway::Workspaces::addWorkspace(const Json::Value &node)
|
|||
if (node["urgent"].asBool()) {
|
||||
button.get_style_context()->add_class("urgent");
|
||||
}
|
||||
button.show();
|
||||
|
||||
onButtonReady(node, button);
|
||||
}
|
||||
|
||||
std::string waybar::modules::sway::Workspaces::getIcon(const std::string &name,
|
||||
|
@ -251,6 +253,19 @@ std::string waybar::modules::sway::Workspaces::trimWorkspaceName(std::string nam
|
|||
return name;
|
||||
}
|
||||
|
||||
void waybar::modules::sway::Workspaces::onButtonReady(const Json::Value& node, Gtk::Button& button)
|
||||
{
|
||||
if (config_["current-only"].asBool()) {
|
||||
if (node["focused"].asBool()) {
|
||||
button.show();
|
||||
} else {
|
||||
button.hide();
|
||||
}
|
||||
} else {
|
||||
button.show();
|
||||
}
|
||||
}
|
||||
|
||||
waybar::modules::sway::Workspaces::operator Gtk::Widget &() {
|
||||
return box_;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue