mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
a194755b4f | |||
165814a57f | |||
![]() |
b665843085 | ||
![]() |
ee4fbc58f7 | ||
![]() |
3081b0c576 | ||
![]() |
b7a527b122 | ||
![]() |
54a6668846 | ||
![]() |
ed0f7453c9 | ||
![]() |
19fe929d1f | ||
![]() |
0a28b50a8c | ||
![]() |
70bc318a01 | ||
![]() |
22817089db | ||
![]() |
aecd80702e | ||
![]() |
abd7a0cf25 | ||
![]() |
e30fba0b8f | ||
![]() |
b5ea14c896 | ||
![]() |
5b33a5917c | ||
![]() |
66b71cc857 | ||
![]() |
c8237437d2 | ||
![]() |
57544fe694 |
76
flake.lock
generated
76
flake.lock
generated
@ -2,15 +2,15 @@
|
||||
"nodes": {
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": "nixpkgs",
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1676293499,
|
||||
"narHash": "sha256-uIOTlTxvrXxpKeTvwBI1JGDGtCxMXE3BI0LFwoQMhiQ=",
|
||||
"lastModified": 1692523566,
|
||||
"narHash": "sha256-VDJDihK6jNebVw9y3qKCVD6+6QaC/x8kxZzL4MaIPPY=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "71e3022e3ab20bbf1342640547ef5bc14fb43bf4",
|
||||
"rev": "d208c58e2f7afef838add5f18a9936b12a71d695",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -36,27 +36,15 @@
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1642700792,
|
||||
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
|
||||
"type": "github"
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"locked": {
|
||||
"lastModified": 1676283394,
|
||||
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=",
|
||||
"lastModified": 1689068808,
|
||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073",
|
||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -67,11 +55,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1643381941,
|
||||
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
|
||||
"lastModified": 1677383253,
|
||||
"narHash": "sha256-UfpzWfSxkfXHnb4boXZNaKsAcUrZT9Hw+tao1oZxd08=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
|
||||
"rev": "9952d6bc395f5841262b006fbace8dd7e143b634",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -83,11 +71,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1676300157,
|
||||
"narHash": "sha256-1HjRzfp6LOLfcj/HJHdVKWAkX9QRAouoh6AjzJiIerU=",
|
||||
"lastModified": 1692638711,
|
||||
"narHash": "sha256-J0LgSFgJVGCC1+j5R2QndadWI1oumusg6hCtYAzLID4=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "545c7a31e5dedea4a6d372712a18e00ce097d462",
|
||||
"rev": "91a22f76cd1716f9d0149e8a5c68424bb691de15",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@ -101,9 +89,39 @@
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
10
flake.nix
10
flake.nix
@ -47,17 +47,12 @@
|
||||
let pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
|
||||
overlays = [ devshell.overlay ];
|
||||
overlays = [ devshell.overlays.default ];
|
||||
};
|
||||
in
|
||||
pkgs.devshell.mkShell {
|
||||
imports = [ "${pkgs.devshell.extraModulesDir}/language/c.nix" ];
|
||||
commands = [
|
||||
{
|
||||
package = pkgs.devshell.cli;
|
||||
help = "Per project developer environments";
|
||||
}
|
||||
];
|
||||
|
||||
devshell.packages = with pkgs; [
|
||||
clang-tools
|
||||
gdb
|
||||
@ -79,6 +74,7 @@
|
||||
at-spi2-atk atkmm cairo cairomm catch2 fmt_8 fontconfig
|
||||
gdk-pixbuf glibmm gtk3 harfbuzz pango pangomm wayland-protocols
|
||||
]);
|
||||
|
||||
env = with pkgs; [
|
||||
{ name = "CPLUS_INCLUDE_PATH"; prefix = "$DEVSHELL_DIR/include"; }
|
||||
{ name = "PKG_CONFIG_PATH"; prefix = "$DEVSHELL_DIR/lib/pkgconfig"; }
|
||||
|
@ -44,23 +44,18 @@ class AModule : public IModule {
|
||||
std::map<std::string, std::string> eventActionMap_;
|
||||
static const inline std::map<std::pair<uint, GdkEventType>, std::string> eventMap_{
|
||||
{std::make_pair(1, GdkEventType::GDK_BUTTON_PRESS), "on-click"},
|
||||
{std::make_pair(1, GdkEventType::GDK_BUTTON_RELEASE), "on-click-release"},
|
||||
{std::make_pair(1, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click"},
|
||||
{std::make_pair(1, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click"},
|
||||
{std::make_pair(2, GdkEventType::GDK_BUTTON_PRESS), "on-click-middle"},
|
||||
{std::make_pair(2, GdkEventType::GDK_BUTTON_RELEASE), "on-click-middle-release"},
|
||||
{std::make_pair(2, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-middle"},
|
||||
{std::make_pair(2, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-middle"},
|
||||
{std::make_pair(3, GdkEventType::GDK_BUTTON_PRESS), "on-click-right"},
|
||||
{std::make_pair(3, GdkEventType::GDK_BUTTON_RELEASE), "on-click-right-release"},
|
||||
{std::make_pair(3, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-right"},
|
||||
{std::make_pair(3, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-right"},
|
||||
{std::make_pair(8, GdkEventType::GDK_BUTTON_PRESS), "on-click-backward"},
|
||||
{std::make_pair(8, GdkEventType::GDK_BUTTON_RELEASE), "on-click-backward-release"},
|
||||
{std::make_pair(8, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-backward"},
|
||||
{std::make_pair(8, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-backward"},
|
||||
{std::make_pair(9, GdkEventType::GDK_BUTTON_PRESS), "on-click-forward"},
|
||||
{std::make_pair(9, GdkEventType::GDK_BUTTON_RELEASE), "on-click-forward-release"},
|
||||
{std::make_pair(9, GdkEventType::GDK_2BUTTON_PRESS), "on-double-click-forward"},
|
||||
{std::make_pair(9, GdkEventType::GDK_3BUTTON_PRESS), "on-triple-click-forward"}};
|
||||
};
|
||||
|
@ -59,7 +59,8 @@ class Bluetooth : public ALabel {
|
||||
auto getDeviceProperties(GDBusObject*, DeviceInfo&) -> bool;
|
||||
auto getControllerProperties(GDBusObject*, ControllerInfo&) -> bool;
|
||||
|
||||
auto findCurController(ControllerInfo&) -> bool;
|
||||
// Returns std::nullopt if no controller could be found
|
||||
auto findCurController() -> std::optional<ControllerInfo>;
|
||||
auto findConnectedDevices(const std::string&, std::vector<DeviceInfo>&) -> void;
|
||||
|
||||
#ifdef WANT_RFKILL
|
||||
@ -68,7 +69,7 @@ class Bluetooth : public ALabel {
|
||||
const std::unique_ptr<GDBusObjectManager, void (*)(GDBusObjectManager*)> manager_;
|
||||
|
||||
std::string state_;
|
||||
ControllerInfo cur_controller_;
|
||||
std::optional<ControllerInfo> cur_controller_;
|
||||
std::vector<DeviceInfo> connected_devices_;
|
||||
DeviceInfo cur_focussed_device_;
|
||||
std::string device_enumerate_;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/args.h>
|
||||
|
||||
#include <csignal>
|
||||
#include <string>
|
||||
@ -34,6 +35,7 @@ class Custom : public ALabel {
|
||||
std::string alt_;
|
||||
std::string tooltip_;
|
||||
std::vector<std::string> class_;
|
||||
fmt::dynamic_format_arg_store<fmt::format_context> fields_;
|
||||
int percentage_;
|
||||
FILE* fp_;
|
||||
int pid_;
|
||||
|
@ -22,10 +22,12 @@ class Workspace {
|
||||
bool is_special() const { return is_special_; };
|
||||
bool is_persistent() const { return is_persistent_; };
|
||||
bool is_empty() const { return windows_ == 0; };
|
||||
bool is_urgent() const { return is_urgent_; };
|
||||
|
||||
auto handle_clicked(GdkEventButton* bt) -> bool;
|
||||
void set_active(bool value = true) { active_ = value; };
|
||||
void set_persistent(bool value = true) { is_persistent_ = value; };
|
||||
void set_urgent(bool value = true) { is_urgent_ = value; };
|
||||
void set_windows(uint value) { windows_ = value; };
|
||||
|
||||
void update(const std::string& format, const std::string& icon);
|
||||
@ -38,6 +40,7 @@ class Workspace {
|
||||
bool active_ = false;
|
||||
bool is_special_ = false;
|
||||
bool is_persistent_ = false;
|
||||
bool is_urgent_ = false;
|
||||
|
||||
Gtk::Button button_;
|
||||
Gtk::Box content_;
|
||||
@ -62,6 +65,7 @@ class Workspaces : public AModule, public EventHandler {
|
||||
void sort_workspaces();
|
||||
void create_workspace(Json::Value& value);
|
||||
void remove_workspace(std::string name);
|
||||
void set_urgent_workspace(std::string windowaddress);
|
||||
|
||||
bool all_outputs_ = false;
|
||||
bool show_special_ = false;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <fmt/chrono.h>
|
||||
#include <gtkmm/label.h>
|
||||
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "AModule.hpp"
|
||||
@ -40,6 +41,7 @@ class KeyboardState : public AModule {
|
||||
|
||||
struct libinput* libinput_;
|
||||
std::unordered_map<std::string, struct libinput_device*> libinput_devices_;
|
||||
std::set<int> binding_keys;
|
||||
|
||||
util::SleeperThread libinput_thread_, hotplug_thread_;
|
||||
};
|
||||
|
@ -93,7 +93,7 @@ template <>
|
||||
struct formatter<Glib::ustring> : formatter<std::string> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Glib::ustring& value, FormatContext& ctx) {
|
||||
return formatter<std::string>::format(value, ctx);
|
||||
return formatter<std::string>::format(static_cast<std::string>(value), ctx);
|
||||
}
|
||||
};
|
||||
} // namespace fmt
|
||||
|
@ -42,6 +42,10 @@ Addressed by *bluetooth*
|
||||
typeof: string ++
|
||||
This format is used when the displayed controller is connected to at least 1 device.
|
||||
|
||||
*format-no-controller*: ++
|
||||
typeof: string ++
|
||||
This format is used when no bluetooth controller could be found
|
||||
|
||||
*format-icons*: ++
|
||||
typeof: array/object ++
|
||||
Based on the current battery percentage (see section *EXPERIMENTAL BATTERY PERCENTAGE FEATURE*), the corresponding icon gets selected. ++
|
||||
@ -113,6 +117,10 @@ Addressed by *bluetooth*
|
||||
typeof: string ++
|
||||
This format is used when the displayed controller is connected to at least 1 device.
|
||||
|
||||
*tooltip-format-no-controller*: ++
|
||||
typeof: string ++
|
||||
This format is used when no bluetooth controller could be found
|
||||
|
||||
*tooltip-format-enumerate-connected*: ++
|
||||
typeof: string ++
|
||||
This format is used to define how each connected device should be displayed within the *device_enumerate* format replacement in the tooltip menu.
|
||||
|
@ -76,3 +76,4 @@ Additional to workspace name matching, the following *format-icons* can be set.
|
||||
- *#workspaces button.active*
|
||||
- *#workspaces button.persistent*
|
||||
- *#workspaces button.special*
|
||||
- *#workspaces button.urgent*
|
||||
|
@ -48,6 +48,11 @@ You must be a member of the input group to use this module.
|
||||
default: chooses first valid input device ++
|
||||
Which libevdev input device to show the state of. Libevdev devices can be found in /dev/input. The device should support number lock, caps lock, and scroll lock events.
|
||||
|
||||
*binding-keys*: ++
|
||||
typeof: array ++
|
||||
default: [58, 69, 70] ++
|
||||
Customize the key to trigger this module, the key number can be find in /usr/include/linux/input-event-codes.h or running sudo libinput debug-events --show-keycodes.
|
||||
|
||||
# FORMAT REPLACEMENTS
|
||||
|
||||
*{name}*: Caps, Num, or Scroll.
|
||||
|
@ -1,6 +1,6 @@
|
||||
project(
|
||||
'waybar', 'cpp', 'c',
|
||||
version: '0.9.21',
|
||||
version: '0.9.22',
|
||||
license: 'MIT',
|
||||
meson_version: '>= 0.50.0',
|
||||
default_options : [
|
||||
|
@ -27,18 +27,20 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
|
||||
}
|
||||
|
||||
// configure events' user commands
|
||||
|
||||
bool hasEvent =
|
||||
std::find_if(eventMap_.cbegin(), eventMap_.cend(), [&config](const auto& eventEntry) {
|
||||
return config[eventEntry.second].isString();
|
||||
}) != eventMap_.cend();
|
||||
|
||||
if (enable_click || hasEvent) {
|
||||
if (enable_click) {
|
||||
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
||||
event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, &AModule::handleToggle));
|
||||
// register key release
|
||||
event_box_.add_events(Gdk::BUTTON_RELEASE_MASK);
|
||||
event_box_.signal_button_release_event().connect(sigc::mem_fun(*this, &AModule::handleToggle));
|
||||
} else {
|
||||
std::map<std::pair<uint, GdkEventType>, std::string>::const_iterator it{eventMap_.cbegin()};
|
||||
while (it != eventMap_.cend()) {
|
||||
if (config_[it->second].isString()) {
|
||||
event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
|
||||
event_box_.signal_button_press_event().connect(
|
||||
sigc::mem_fun(*this, &AModule::handleToggle));
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
}
|
||||
if (config_["on-scroll-up"].isString() || config_["on-scroll-down"].isString() || enable_scroll) {
|
||||
event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
|
||||
|
@ -92,28 +92,30 @@ waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value&
|
||||
std::back_inserter(device_preference_), [](auto x) { return x.asString(); });
|
||||
}
|
||||
|
||||
// NOTE: assumption made that the controller that is selcected stays unchanged
|
||||
// NOTE: assumption made that the controller that is selected stays unchanged
|
||||
// for duration of the module
|
||||
if (!findCurController(cur_controller_)) {
|
||||
if (cur_controller_ = findCurController(); !cur_controller_) {
|
||||
if (config_["controller-alias"].isString()) {
|
||||
spdlog::error("findCurController() failed: no bluetooth controller found with alias '{}'",
|
||||
config_["controller-alias"].asString());
|
||||
} else {
|
||||
spdlog::error("findCurController() failed: no bluetooth controller found");
|
||||
}
|
||||
event_box_.hide();
|
||||
return;
|
||||
}
|
||||
findConnectedDevices(cur_controller_.path, connected_devices_);
|
||||
update();
|
||||
} else {
|
||||
// These calls only make sense if a controller could be found
|
||||
findConnectedDevices(cur_controller_->path, connected_devices_);
|
||||
g_signal_connect(manager_.get(), "interface-proxy-properties-changed",
|
||||
G_CALLBACK(onInterfaceProxyPropertiesChanged), this);
|
||||
g_signal_connect(manager_.get(), "interface-added", G_CALLBACK(onInterfaceAddedOrRemoved),
|
||||
this);
|
||||
g_signal_connect(manager_.get(), "interface-removed", G_CALLBACK(onInterfaceAddedOrRemoved),
|
||||
this);
|
||||
|
||||
g_signal_connect(manager_.get(), "interface-proxy-properties-changed",
|
||||
G_CALLBACK(onInterfaceProxyPropertiesChanged), this);
|
||||
g_signal_connect(manager_.get(), "interface-added", G_CALLBACK(onInterfaceAddedOrRemoved), this);
|
||||
g_signal_connect(manager_.get(), "interface-removed", G_CALLBACK(onInterfaceAddedOrRemoved),
|
||||
this);
|
||||
#ifdef WANT_RFKILL
|
||||
rfkill_.on_update.connect(sigc::hide(sigc::mem_fun(*this, &Bluetooth::update)));
|
||||
rfkill_.on_update.connect(sigc::hide(sigc::mem_fun(*this, &Bluetooth::update)));
|
||||
#endif
|
||||
}
|
||||
|
||||
dp.emit();
|
||||
}
|
||||
@ -144,12 +146,16 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
|
||||
std::string state;
|
||||
std::string tooltip_format;
|
||||
if (!cur_controller_.powered)
|
||||
state = "off";
|
||||
else if (!connected_devices_.empty())
|
||||
state = "connected";
|
||||
else
|
||||
state = "on";
|
||||
if (cur_controller_) {
|
||||
if (!cur_controller_->powered)
|
||||
state = "off";
|
||||
else if (!connected_devices_.empty())
|
||||
state = "connected";
|
||||
else
|
||||
state = "on";
|
||||
} else {
|
||||
state = "no-controller";
|
||||
}
|
||||
#ifdef WANT_RFKILL
|
||||
if (rfkill_.getState()) state = "disabled";
|
||||
#endif
|
||||
@ -187,8 +193,6 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
tooltip_format = config_["tooltip-format"].asString();
|
||||
}
|
||||
|
||||
format_.empty() ? event_box_.hide() : event_box_.show();
|
||||
|
||||
auto update_style_context = [this](const std::string& style_class, bool in_next_state) {
|
||||
if (in_next_state && !label_.get_style_context()->has_class(style_class)) {
|
||||
label_.get_style_context()->add_class(style_class);
|
||||
@ -196,25 +200,32 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
label_.get_style_context()->remove_class(style_class);
|
||||
}
|
||||
};
|
||||
update_style_context("discoverable", cur_controller_.discoverable);
|
||||
update_style_context("discovering", cur_controller_.discovering);
|
||||
update_style_context("pairable", cur_controller_.pairable);
|
||||
update_style_context("discoverable", cur_controller_ ? cur_controller_->discoverable : false);
|
||||
update_style_context("discovering", cur_controller_ ? cur_controller_->discovering : false);
|
||||
update_style_context("pairable", cur_controller_ ? cur_controller_->pairable : false);
|
||||
if (!state_.empty()) {
|
||||
update_style_context(state_, false);
|
||||
}
|
||||
update_style_context(state, true);
|
||||
state_ = state;
|
||||
|
||||
label_.set_markup(fmt::format(
|
||||
fmt::runtime(format_), fmt::arg("status", state_),
|
||||
fmt::arg("num_connections", connected_devices_.size()),
|
||||
fmt::arg("controller_address", cur_controller_.address),
|
||||
fmt::arg("controller_address_type", cur_controller_.address_type),
|
||||
fmt::arg("controller_alias", cur_controller_.alias),
|
||||
fmt::arg("device_address", cur_focussed_device_.address),
|
||||
fmt::arg("device_address_type", cur_focussed_device_.address_type),
|
||||
fmt::arg("device_alias", cur_focussed_device_.alias), fmt::arg("icon", icon_label),
|
||||
fmt::arg("device_battery_percentage", cur_focussed_device_.battery_percentage.value_or(0))));
|
||||
if (format_.empty()) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
event_box_.show();
|
||||
label_.set_markup(fmt::format(
|
||||
fmt::runtime(format_), fmt::arg("status", state_),
|
||||
fmt::arg("num_connections", connected_devices_.size()),
|
||||
fmt::arg("controller_address", cur_controller_ ? cur_controller_->address : "null"),
|
||||
fmt::arg("controller_address_type",
|
||||
cur_controller_ ? cur_controller_->address_type : "null"),
|
||||
fmt::arg("controller_alias", cur_controller_ ? cur_controller_->alias : "null"),
|
||||
fmt::arg("device_address", cur_focussed_device_.address),
|
||||
fmt::arg("device_address_type", cur_focussed_device_.address_type),
|
||||
fmt::arg("device_alias", cur_focussed_device_.alias), fmt::arg("icon", icon_label),
|
||||
fmt::arg("device_battery_percentage",
|
||||
cur_focussed_device_.battery_percentage.value_or(0))));
|
||||
}
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
bool tooltip_enumerate_connections_ = config_["tooltip-format-enumerate-connected"].isString();
|
||||
@ -250,9 +261,10 @@ auto waybar::modules::Bluetooth::update() -> void {
|
||||
label_.set_tooltip_text(fmt::format(
|
||||
fmt::runtime(tooltip_format), fmt::arg("status", state_),
|
||||
fmt::arg("num_connections", connected_devices_.size()),
|
||||
fmt::arg("controller_address", cur_controller_.address),
|
||||
fmt::arg("controller_address_type", cur_controller_.address_type),
|
||||
fmt::arg("controller_alias", cur_controller_.alias),
|
||||
fmt::arg("controller_address", cur_controller_ ? cur_controller_->address : "null"),
|
||||
fmt::arg("controller_address_type",
|
||||
cur_controller_ ? cur_controller_->address_type : "null"),
|
||||
fmt::arg("controller_alias", cur_controller_ ? cur_controller_->alias : "null"),
|
||||
fmt::arg("device_address", cur_focussed_device_.address),
|
||||
fmt::arg("device_address_type", cur_focussed_device_.address_type),
|
||||
fmt::arg("device_alias", cur_focussed_device_.alias), fmt::arg("icon", icon_tooltip),
|
||||
@ -292,8 +304,8 @@ auto waybar::modules::Bluetooth::onInterfaceProxyPropertiesChanged(
|
||||
|
||||
Bluetooth* bt = static_cast<Bluetooth*>(user_data);
|
||||
if (interface_name == "org.bluez.Adapter1") {
|
||||
if (object_path == bt->cur_controller_.path) {
|
||||
bt->getControllerProperties(G_DBUS_OBJECT(object_proxy), bt->cur_controller_);
|
||||
if (object_path == bt->cur_controller_->path) {
|
||||
bt->getControllerProperties(G_DBUS_OBJECT(object_proxy), *bt->cur_controller_);
|
||||
bt->dp.emit();
|
||||
}
|
||||
} else if (interface_name == "org.bluez.Device1" || interface_name == "org.bluez.Battery1") {
|
||||
@ -378,22 +390,23 @@ auto waybar::modules::Bluetooth::getControllerProperties(GDBusObject* object,
|
||||
return false;
|
||||
}
|
||||
|
||||
auto waybar::modules::Bluetooth::findCurController(ControllerInfo& controller_info) -> bool {
|
||||
bool found_controller = false;
|
||||
auto waybar::modules::Bluetooth::findCurController() -> std::optional<ControllerInfo> {
|
||||
std::optional<ControllerInfo> controller_info;
|
||||
|
||||
GList* objects = g_dbus_object_manager_get_objects(manager_.get());
|
||||
for (GList* l = objects; l != NULL; l = l->next) {
|
||||
GDBusObject* object = G_DBUS_OBJECT(l->data);
|
||||
if (getControllerProperties(object, controller_info) &&
|
||||
ControllerInfo info;
|
||||
if (getControllerProperties(object, info) &&
|
||||
(!config_["controller-alias"].isString() ||
|
||||
config_["controller-alias"].asString() == controller_info.alias)) {
|
||||
found_controller = true;
|
||||
config_["controller-alias"].asString() == info.alias)) {
|
||||
controller_info = std::move(info);
|
||||
break;
|
||||
}
|
||||
}
|
||||
g_list_free_full(objects, g_object_unref);
|
||||
|
||||
return found_controller;
|
||||
return controller_info;
|
||||
}
|
||||
|
||||
auto waybar::modules::Bluetooth::findConnectedDevices(const std::string& cur_controller_path,
|
||||
@ -404,7 +417,7 @@ auto waybar::modules::Bluetooth::findConnectedDevices(const std::string& cur_con
|
||||
GDBusObject* object = G_DBUS_OBJECT(l->data);
|
||||
DeviceInfo device;
|
||||
if (getDeviceProperties(object, device) && device.connected &&
|
||||
device.paired_controller == cur_controller_.path) {
|
||||
device.paired_controller == cur_controller_->path) {
|
||||
connected_devices.push_back(device);
|
||||
}
|
||||
}
|
||||
|
@ -122,14 +122,14 @@ auto waybar::modules::Custom::update() -> void {
|
||||
(output_.out.empty() || output_.exit_code != 0)) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
fields_.clear();
|
||||
if (config_["return-type"].asString() == "json") {
|
||||
parseOutputJson();
|
||||
} else {
|
||||
parseOutputRaw();
|
||||
}
|
||||
auto str = fmt::format(fmt::runtime(format_), text_, fmt::arg("alt", alt_),
|
||||
fmt::arg("icon", getIcon(percentage_, alt_)),
|
||||
fmt::arg("percentage", percentage_));
|
||||
auto str = fmt::vformat(format_, fields_);
|
||||
|
||||
if (str.empty()) {
|
||||
event_box_.hide();
|
||||
} else {
|
||||
@ -173,6 +173,7 @@ void waybar::modules::Custom::parseOutputRaw() {
|
||||
} else {
|
||||
text_ = line;
|
||||
}
|
||||
fields_.push_back(text_);
|
||||
tooltip_ = line;
|
||||
class_.clear();
|
||||
} else if (i == 1) {
|
||||
@ -189,32 +190,45 @@ void waybar::modules::Custom::parseOutputRaw() {
|
||||
void waybar::modules::Custom::parseOutputJson() {
|
||||
std::istringstream output(output_.out);
|
||||
std::string line;
|
||||
getline(output, line);
|
||||
class_.clear();
|
||||
while (getline(output, line)) {
|
||||
auto parsed = parser_.parse(line);
|
||||
auto parsed = parser_.parse(line);
|
||||
|
||||
// Preserve order so that first "{}" is resolved to "text" for backwards compatability
|
||||
if (parsed["text"].isString()) {
|
||||
auto str = parsed["text"].asString();
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
text_ = Glib::Markup::escape_text(parsed["text"].asString());
|
||||
} else {
|
||||
text_ = parsed["text"].asString();
|
||||
str = Glib::Markup::escape_text(str);
|
||||
}
|
||||
fields_.push_back(str);
|
||||
}
|
||||
|
||||
for (auto const& key : parsed.getMemberNames()) {
|
||||
if (!parsed[key].isString()) continue;
|
||||
auto str = parsed[key].asString();
|
||||
if (config_["escape"].isBool() && config_["escape"].asBool()) {
|
||||
alt_ = Glib::Markup::escape_text(parsed["alt"].asString());
|
||||
} else {
|
||||
alt_ = parsed["alt"].asString();
|
||||
str = Glib::Markup::escape_text(str);
|
||||
}
|
||||
tooltip_ = parsed["tooltip"].asString();
|
||||
if (parsed["class"].isString()) {
|
||||
class_.push_back(parsed["class"].asString());
|
||||
} else if (parsed["class"].isArray()) {
|
||||
for (auto const& c : parsed["class"]) {
|
||||
class_.push_back(c.asString());
|
||||
}
|
||||
fields_.push_back(fmt::arg(key.c_str(), str));
|
||||
}
|
||||
|
||||
tooltip_ = parsed["tooltip"].asString();
|
||||
if (parsed["class"].isString()) {
|
||||
class_.push_back(parsed["class"].asString());
|
||||
} else if (parsed["class"].isArray()) {
|
||||
for (auto const& c : parsed["class"]) {
|
||||
class_.push_back(c.asString());
|
||||
}
|
||||
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isNumeric()) {
|
||||
percentage_ = (int)lround(parsed["percentage"].asFloat());
|
||||
} else {
|
||||
percentage_ = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!parsed["percentage"].asString().empty() && parsed["percentage"].isNumeric()) {
|
||||
percentage_ = (int)lround(parsed["percentage"].asFloat());
|
||||
} else {
|
||||
percentage_ = 0;
|
||||
}
|
||||
|
||||
// Allow overriding icon from json, otherwise use percentage based icon
|
||||
if (parsed["icon"].isNull()) {
|
||||
fields_.push_back(fmt::arg("icon", getIcon(percentage_, alt_)));
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,7 @@ Workspaces::Workspaces(const std::string &id, const Bar &bar, const Json::Value
|
||||
gIPC->registerForIPC("openwindow", this);
|
||||
gIPC->registerForIPC("closewindow", this);
|
||||
gIPC->registerForIPC("movewindow", this);
|
||||
gIPC->registerForIPC("urgent", this);
|
||||
}
|
||||
|
||||
auto Workspaces::update() -> void {
|
||||
@ -75,6 +76,9 @@ auto Workspaces::update() -> void {
|
||||
|
||||
for (auto &workspace : workspaces_) {
|
||||
workspace->set_active(workspace->name() == active_workspace_name_);
|
||||
if (workspace->name() == active_workspace_name_ && workspace.get()->is_urgent()) {
|
||||
workspace->set_urgent(false);
|
||||
}
|
||||
std::string &workspace_icon = icons_map_[""];
|
||||
if (with_icon_) {
|
||||
workspace_icon = workspace->select_icon(icons_map_);
|
||||
@ -126,6 +130,8 @@ void Workspaces::onEvent(const std::string &ev) {
|
||||
}
|
||||
} else if (eventName == "openwindow" || eventName == "closewindow" || eventName == "movewindow") {
|
||||
update_window_count();
|
||||
} else if (eventName == "urgent") {
|
||||
set_urgent_workspace(payload);
|
||||
}
|
||||
|
||||
dp.emit();
|
||||
@ -323,6 +329,7 @@ void Workspace::update(const std::string &format, const std::string &icon) {
|
||||
add_or_remove_class(style_context, active(), "active");
|
||||
add_or_remove_class(style_context, is_special(), "special");
|
||||
add_or_remove_class(style_context, is_empty(), "persistent");
|
||||
add_or_remove_class(style_context, is_urgent(), "urgent");
|
||||
|
||||
label_.set_markup(fmt::format(fmt::runtime(format), fmt::arg("id", id()),
|
||||
fmt::arg("name", name()), fmt::arg("icon", icon)));
|
||||
@ -419,4 +426,23 @@ auto Workspace::handle_clicked(GdkEventButton *bt) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Workspaces::set_urgent_workspace(std::string windowaddress) {
|
||||
const Json::Value clients_json = gIPC->getSocket1JsonReply("clients");
|
||||
int workspace_id;
|
||||
|
||||
for (Json::Value client_json : clients_json) {
|
||||
if (client_json["address"].asString().ends_with(windowaddress)) {
|
||||
workspace_id = client_json["workspace"]["id"].asInt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto workspace =
|
||||
std::find_if(workspaces_.begin(), workspaces_.end(),
|
||||
[&](std::unique_ptr<Workspace> &x) { return x->id() == workspace_id; });
|
||||
if (workspace->get() != nullptr) {
|
||||
workspace->get()->set_urgent();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace waybar::modules::hyprland
|
||||
|
@ -142,6 +142,21 @@ waybar::modules::KeyboardState::KeyboardState(const std::string& id, const Bar&
|
||||
}
|
||||
}
|
||||
|
||||
auto keys = config_["binding-keys"];
|
||||
if (keys.isArray()) {
|
||||
for (const auto& key : keys) {
|
||||
if (key.isInt()) {
|
||||
binding_keys.insert(key.asInt());
|
||||
} else {
|
||||
spdlog::warn("Cannot read key binding {} as int.", key.asString());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
binding_keys.insert(KEY_CAPSLOCK);
|
||||
binding_keys.insert(KEY_NUMLOCK);
|
||||
binding_keys.insert(KEY_SCROLLLOCK);
|
||||
}
|
||||
|
||||
DIR* dev_dir = opendir(devices_path_.c_str());
|
||||
if (dev_dir == nullptr) {
|
||||
throw errno_error(errno, "Failed to open " + devices_path_);
|
||||
@ -171,14 +186,8 @@ waybar::modules::KeyboardState::KeyboardState(const std::string& id, const Bar&
|
||||
auto state = libinput_event_keyboard_get_key_state(keyboard_event);
|
||||
if (state == LIBINPUT_KEY_STATE_RELEASED) {
|
||||
uint32_t key = libinput_event_keyboard_get_key(keyboard_event);
|
||||
switch (key) {
|
||||
case KEY_CAPSLOCK:
|
||||
case KEY_NUMLOCK:
|
||||
case KEY_SCROLLLOCK:
|
||||
dp.emit();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
if (binding_keys.contains(key)) {
|
||||
dp.emit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,13 +18,13 @@ auto waybar::modules::Clock::update() -> void {
|
||||
tzset(); // Update timezone information
|
||||
auto now = std::chrono::system_clock::now();
|
||||
auto localtime = fmt::localtime(std::chrono::system_clock::to_time_t(now));
|
||||
auto text = fmt::format(format_, localtime);
|
||||
auto text = fmt::format(fmt::runtime(format_), localtime);
|
||||
label_.set_markup(text);
|
||||
|
||||
if (tooltipEnabled()) {
|
||||
if (config_["tooltip-format"].isString()) {
|
||||
auto tooltip_format = config_["tooltip-format"].asString();
|
||||
auto tooltip_text = fmt::format(tooltip_format, localtime);
|
||||
auto tooltip_text = fmt::format(fmt::runtime(tooltip_format), localtime);
|
||||
label_.set_tooltip_text(tooltip_text);
|
||||
} else {
|
||||
label_.set_tooltip_text(text);
|
||||
|
@ -22,7 +22,7 @@ struct fmt::formatter<Glib::VariantBase> : formatter<std::string> {
|
||||
template <typename FormatContext>
|
||||
auto format(const Glib::VariantBase& value, FormatContext& ctx) {
|
||||
if (is_printable(value)) {
|
||||
return formatter<std::string>::format(value.print(), ctx);
|
||||
return formatter<std::string>::format(static_cast<std::string>(value.print()), ctx);
|
||||
} else {
|
||||
return formatter<std::string>::format(value.get_type_string(), ctx);
|
||||
}
|
||||
|
@ -517,7 +517,7 @@ void Task::handle_closed() {
|
||||
bool Task::handle_clicked(GdkEventButton *bt) {
|
||||
/* filter out additional events for double/triple clicks */
|
||||
if (bt->type == GDK_BUTTON_PRESS) {
|
||||
/* save where the button press ocurred in case it becomes a drag */
|
||||
/* save where the button press occurred in case it becomes a drag */
|
||||
drag_start_button = bt->button;
|
||||
drag_start_x = bt->x;
|
||||
drag_start_y = bt->y;
|
||||
|
@ -1,10 +1,10 @@
|
||||
[wrap-file]
|
||||
directory = Catch2-3.3.2
|
||||
source_url = https://github.com/catchorg/Catch2/archive/v3.3.2.tar.gz
|
||||
source_filename = Catch2-3.3.2.tar.gz
|
||||
source_hash = 8361907f4d9bff3ae7c1edb027f813659f793053c99b67837a0c0375f065bae2
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/catch2_3.3.2-1/Catch2-3.3.2.tar.gz
|
||||
wrapdb_version = 3.3.2-1
|
||||
directory = Catch2-3.4.0
|
||||
source_url = https://github.com/catchorg/Catch2/archive/v3.4.0.tar.gz
|
||||
source_filename = Catch2-3.4.0.tar.gz
|
||||
source_hash = 122928b814b75717316c71af69bd2b43387643ba076a6ec16e7882bfb2dfacbb
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/catch2_3.4.0-1/Catch2-3.4.0.tar.gz
|
||||
wrapdb_version = 3.4.0-1
|
||||
|
||||
[provide]
|
||||
catch2 = catch2_dep
|
||||
|
@ -1,12 +1,13 @@
|
||||
[wrap-file]
|
||||
directory = fmt-8.1.1
|
||||
source_url = https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz
|
||||
source_filename = fmt-8.1.1.tar.gz
|
||||
source_hash = 3d794d3cf67633b34b2771eb9f073bde87e846e0d395d254df7b211ef1ec7346
|
||||
patch_filename = fmt_8.1.1-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_8.1.1-1/get_patch
|
||||
patch_hash = 6035a67c7a8c90bed74c293c7265c769f47a69816125f7566bccb8e2543cee5e
|
||||
directory = fmt-9.1.0
|
||||
source_url = https://github.com/fmtlib/fmt/archive/9.1.0.tar.gz
|
||||
source_filename = fmt-9.1.0.tar.gz
|
||||
source_hash = 5dea48d1fcddc3ec571ce2058e13910a0d4a6bab4cc09a809d8b1dd1c88ae6f2
|
||||
patch_filename = fmt_9.1.0-2_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/fmt_9.1.0-2/get_patch
|
||||
patch_hash = 23e8c4829f3e63f509b5643fe6bb87cbed39eae9594c451b338475d14d051967
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_9.1.0-2/fmt-9.1.0.tar.gz
|
||||
wrapdb_version = 9.1.0-2
|
||||
|
||||
[provide]
|
||||
fmt = fmt_dep
|
||||
|
||||
|
@ -1,13 +1,12 @@
|
||||
[wrap-file]
|
||||
directory = spdlog-1.10.0
|
||||
source_url = https://github.com/gabime/spdlog/archive/v1.10.0.tar.gz
|
||||
source_filename = v1.10.0.tar.gz
|
||||
source_hash = 697f91700237dbae2326b90469be32b876b2b44888302afbc7aceb68bcfe8224
|
||||
patch_filename = spdlog_1.10.0-3_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.10.0-3/get_patch
|
||||
patch_hash = 5bb07b4af1e971817d4b886efbe077aaf6c36d72d3d7e461bbcf6631f3725704
|
||||
wrapdb_version = 1.10.0-3
|
||||
directory = spdlog-1.11.0
|
||||
source_url = https://github.com/gabime/spdlog/archive/v1.11.0.tar.gz
|
||||
source_filename = v1.11.0.tar.gz
|
||||
source_hash = ca5cae8d6cac15dae0ec63b21d6ad3530070650f68076f3a4a862ca293a858bb
|
||||
patch_filename = spdlog_1.11.0-2_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.11.0-2/get_patch
|
||||
patch_hash = db1364fe89502ac67f245a6c8c51290a52afd74a51eed26fa9ecb5b3443df57a
|
||||
wrapdb_version = 1.11.0-2
|
||||
|
||||
[provide]
|
||||
spdlog = spdlog_dep
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user