feat(workspaces): add a option to show all workspaces from all outputs

This commit is contained in:
Alexis 2018-08-15 22:19:17 +02:00
parent 3ed3416d75
commit a9246a09eb
3 changed files with 11 additions and 8 deletions

View File

@ -9,6 +9,7 @@
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"],
// Modules configuration
"sway/workspaces": {
// "all-outputs": true,
"format-icons": {
"1": "",
"2": "",

View File

@ -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

View File

@ -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
// 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()) {