Merge branch 'master' into swaybar-ipc
commit
05f7727dae
|
@ -98,7 +98,7 @@ class Bar {
|
||||||
private:
|
private:
|
||||||
void onMap(GdkEventAny *);
|
void onMap(GdkEventAny *);
|
||||||
auto setupWidgets() -> void;
|
auto setupWidgets() -> void;
|
||||||
void getModules(const Factory &, const std::string &);
|
void getModules(const Factory &, const std::string &, Gtk::Box*);
|
||||||
void setupAltFormatKeyForModule(const std::string &module_name);
|
void setupAltFormatKeyForModule(const std::string &module_name);
|
||||||
void setupAltFormatKeyForModuleList(const char *module_list_name);
|
void setupAltFormatKeyForModuleList(const char *module_list_name);
|
||||||
void setMode(const bar_mode &);
|
void setMode(const bar_mode &);
|
||||||
|
@ -119,6 +119,7 @@ class Bar {
|
||||||
using BarIpcClient = modules::sway::BarIpcClient;
|
using BarIpcClient = modules::sway::BarIpcClient;
|
||||||
std::unique_ptr<BarIpcClient> _ipc_client;
|
std::unique_ptr<BarIpcClient> _ipc_client;
|
||||||
#endif
|
#endif
|
||||||
|
std::vector<std::unique_ptr<waybar::AModule>> modules_all_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace waybar
|
} // namespace waybar
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <gtkmm/widget.h>
|
||||||
|
#include <gtkmm/box.h>
|
||||||
|
#include <json/json.h>
|
||||||
|
#include "AModule.hpp"
|
||||||
|
#include "bar.hpp"
|
||||||
|
#include "factory.hpp"
|
||||||
|
|
||||||
|
namespace waybar {
|
||||||
|
|
||||||
|
class Group : public AModule {
|
||||||
|
public:
|
||||||
|
Group(const std::string&, const Bar&, const Json::Value&);
|
||||||
|
~Group() = default;
|
||||||
|
auto update() -> void;
|
||||||
|
operator Gtk::Widget &();
|
||||||
|
Gtk::Box box;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace waybar
|
|
@ -218,6 +218,28 @@ When positioning Waybar on the left or right side of the screen, sometimes it's
|
||||||
|
|
||||||
Valid options for the "rotate" property are: 0, 90, 180 and 270.
|
Valid options for the "rotate" property are: 0, 90, 180 and 270.
|
||||||
|
|
||||||
|
## Grouping modules
|
||||||
|
|
||||||
|
Module groups allow stacking modules in the direction orthogonal to the bar direction. When the bar is positioned on the top or bottom of the screen, modules in a group are stacked vertically. Likewise, when positioned on the left or right, modules in a group are stacked horizontally.
|
||||||
|
|
||||||
|
A module group is defined by specifying a module named "group/some-group-name". The group must also be configured with a list of contained modules. Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"modules-right": ["group/hardware", "clock"],
|
||||||
|
|
||||||
|
"group/hardware": {
|
||||||
|
"modules": [
|
||||||
|
"cpu",
|
||||||
|
"memory",
|
||||||
|
"battery"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
# SUPPORTED MODULES
|
# SUPPORTED MODULES
|
||||||
|
|
||||||
- *waybar-backlight(5)*
|
- *waybar-backlight(5)*
|
||||||
|
|
|
@ -150,6 +150,7 @@ src_files = files(
|
||||||
'src/bar.cpp',
|
'src/bar.cpp',
|
||||||
'src/client.cpp',
|
'src/client.cpp',
|
||||||
'src/config.cpp',
|
'src/config.cpp',
|
||||||
|
'src/group.cpp',
|
||||||
'src/util/ustring_clen.cpp'
|
'src/util/ustring_clen.cpp'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
39
src/bar.cpp
39
src/bar.cpp
|
@ -9,6 +9,7 @@
|
||||||
#include "bar.hpp"
|
#include "bar.hpp"
|
||||||
#include "client.hpp"
|
#include "client.hpp"
|
||||||
#include "factory.hpp"
|
#include "factory.hpp"
|
||||||
|
#include "group.hpp"
|
||||||
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
#include "wlr-layer-shell-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
#ifdef HAVE_SWAY
|
#ifdef HAVE_SWAY
|
||||||
|
@ -710,19 +711,7 @@ void waybar::Bar::setupAltFormatKeyForModuleList(const char* module_list_name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::Bar::handleSignal(int signal) {
|
void waybar::Bar::handleSignal(int signal) {
|
||||||
for (auto& module : modules_left_) {
|
for (auto& module : modules_all_) {
|
||||||
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
|
||||||
if (custom != nullptr) {
|
|
||||||
custom->refresh(signal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& module : modules_center_) {
|
|
||||||
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
|
||||||
if (custom != nullptr) {
|
|
||||||
custom->refresh(signal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& module : modules_right_) {
|
|
||||||
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
auto* custom = dynamic_cast<waybar::modules::Custom*>(module.get());
|
||||||
if (custom != nullptr) {
|
if (custom != nullptr) {
|
||||||
custom->refresh(signal);
|
custom->refresh(signal);
|
||||||
|
@ -730,11 +719,26 @@ void waybar::Bar::handleSignal(int signal) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void waybar::Bar::getModules(const Factory& factory, const std::string& pos) {
|
void waybar::Bar::getModules(const Factory& factory, const std::string& pos, Gtk::Box* group = nullptr) {
|
||||||
if (config[pos].isArray()) {
|
auto module_list = group ? config[pos]["modules"] : config[pos];
|
||||||
for (const auto& name : config[pos]) {
|
if (module_list.isArray()) {
|
||||||
|
for (const auto& name : module_list) {
|
||||||
try {
|
try {
|
||||||
auto module = factory.makeModule(name.asString());
|
auto ref = name.asString();
|
||||||
|
AModule* module;
|
||||||
|
|
||||||
|
if (ref.compare(0, 6, "group/") == 0 && ref.size() > 6) {
|
||||||
|
auto group_module = new waybar::Group(ref, *this, config[ref]);
|
||||||
|
getModules(factory, ref, &group_module->box);
|
||||||
|
module = group_module;
|
||||||
|
} else {
|
||||||
|
module = factory.makeModule(ref);
|
||||||
|
}
|
||||||
|
|
||||||
|
modules_all_.emplace_back(module);
|
||||||
|
if (group) {
|
||||||
|
group->pack_start(*module, false, false);
|
||||||
|
} else {
|
||||||
if (pos == "modules-left") {
|
if (pos == "modules-left") {
|
||||||
modules_left_.emplace_back(module);
|
modules_left_.emplace_back(module);
|
||||||
}
|
}
|
||||||
|
@ -744,6 +748,7 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos) {
|
||||||
if (pos == "modules-right") {
|
if (pos == "modules-right") {
|
||||||
modules_right_.emplace_back(module);
|
modules_right_.emplace_back(module);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
module->dp.connect([module, &name] {
|
module->dp.connect([module, &name] {
|
||||||
try {
|
try {
|
||||||
module->update();
|
module->update();
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#include "group.hpp"
|
||||||
|
#include <fmt/format.h>
|
||||||
|
#include <util/command.hpp>
|
||||||
|
|
||||||
|
namespace waybar {
|
||||||
|
|
||||||
|
Group::Group(const std::string& name, const Bar& bar, const Json::Value& config)
|
||||||
|
: AModule(config, name, "", false, false),
|
||||||
|
box{bar.vertical ? Gtk::ORIENTATION_HORIZONTAL : Gtk::ORIENTATION_VERTICAL, 0}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
auto Group::update() -> void {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
Group::operator Gtk::Widget&() { return box; }
|
||||||
|
|
||||||
|
} // namespace waybar
|
|
@ -211,7 +211,7 @@ static const std::array<std::string, 9> ports = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<std::string> waybar::modules::Pulseaudio::getPulseIcon() const {
|
const std::vector<std::string> waybar::modules::Pulseaudio::getPulseIcon() const {
|
||||||
std::vector<std::string> res = {default_source_name_};
|
std::vector<std::string> res = {current_sink_name_, default_source_name_};
|
||||||
std::string nameLC = port_name_ + form_factor_;
|
std::string nameLC = port_name_ + form_factor_;
|
||||||
std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower);
|
std::transform(nameLC.begin(), nameLC.end(), nameLC.begin(), ::tolower);
|
||||||
for (auto const &port : ports) {
|
for (auto const &port : ports) {
|
||||||
|
|
Loading…
Reference in New Issue