mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
feat(workspaces): add a option to show all workspaces from all outputs
This commit is contained in:
parent
3ed3416d75
commit
a9246a09eb
@ -9,6 +9,7 @@
|
||||
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"],
|
||||
// Modules configuration
|
||||
"sway/workspaces": {
|
||||
// "all-outputs": true,
|
||||
"format-icons": {
|
||||
"1": "",
|
||||
"2": "",
|
||||
|
@ -37,14 +37,14 @@ auto waybar::modules::Battery::update() -> void
|
||||
{
|
||||
try {
|
||||
uint16_t total = 0;
|
||||
bool charging = false;
|
||||
std::string status;
|
||||
for (auto &bat : _batteries) {
|
||||
uint16_t capacity;
|
||||
std::string _status;
|
||||
std::ifstream(bat / "capacity") >> capacity;
|
||||
std::ifstream(bat / "status") >> status;
|
||||
if (status == "Charging")
|
||||
charging = true;
|
||||
std::ifstream(bat / "status") >> _status;
|
||||
if (_status != "Unknown")
|
||||
status = _status;
|
||||
total += capacity;
|
||||
}
|
||||
uint16_t capacity = total / _batteries.size();
|
||||
@ -53,6 +53,7 @@ auto waybar::modules::Battery::update() -> void
|
||||
_label.set_text(fmt::format(format, fmt::arg("capacity", capacity),
|
||||
fmt::arg("icon", _getIcon(capacity))));
|
||||
_label.set_tooltip_text(status);
|
||||
bool charging = status == "Charging";
|
||||
if (charging)
|
||||
_label.get_style_context()->add_class("charging");
|
||||
else
|
||||
|
@ -13,11 +13,11 @@ waybar::modules::sway::Workspaces::Workspaces(Bar &bar, Json::Value config)
|
||||
ipc_single_command(_ipcEventfd, IPC_SUBSCRIBE, subscribe, &len);
|
||||
_thread = [this] {
|
||||
try {
|
||||
if (_bar.outputName.empty()) {
|
||||
// Wait for the name of the output
|
||||
if (!_config["all-outputs"].asBool() && _bar.outputName.empty()) {
|
||||
while (_bar.outputName.empty())
|
||||
_thread.sleep_for(chrono::milliseconds(150));
|
||||
} else
|
||||
} else if (_workspaces.size())
|
||||
ipc_recv_response(_ipcEventfd);
|
||||
uint32_t len = 0;
|
||||
std::lock_guard<std::mutex> lock(_mutex);
|
||||
@ -45,7 +45,8 @@ auto waybar::modules::sway::Workspaces::update() -> void
|
||||
++it;
|
||||
}
|
||||
for (auto node : _workspaces) {
|
||||
if (_bar.outputName != node["output"].asString())
|
||||
if (!_config["all-outputs"].asBool()
|
||||
&& _bar.outputName != node["output"].asString())
|
||||
continue;
|
||||
auto it = _buttons.find(node["num"].asInt());
|
||||
if (it == _buttons.end()) {
|
||||
|
Loading…
Reference in New Issue
Block a user