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-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"], | ||||||
|     // Modules configuration |     // Modules configuration | ||||||
|     "sway/workspaces": { |     "sway/workspaces": { | ||||||
|  |         // "all-outputs": true, | ||||||
|         "format-icons": { |         "format-icons": { | ||||||
|             "1": "", |             "1": "", | ||||||
|             "2": "", |             "2": "", | ||||||
|  |  | ||||||
|  | @ -37,14 +37,14 @@ auto waybar::modules::Battery::update() -> void | ||||||
| { | { | ||||||
|   try { |   try { | ||||||
|     uint16_t total = 0; |     uint16_t total = 0; | ||||||
|     bool charging = false; |  | ||||||
|     std::string status; |     std::string status; | ||||||
|     for (auto &bat : _batteries) { |     for (auto &bat : _batteries) { | ||||||
|       uint16_t capacity; |       uint16_t capacity; | ||||||
|  |       std::string _status; | ||||||
|       std::ifstream(bat / "capacity") >> capacity; |       std::ifstream(bat / "capacity") >> capacity; | ||||||
|       std::ifstream(bat / "status") >> status; |       std::ifstream(bat / "status") >> _status; | ||||||
|       if (status == "Charging") |       if (_status != "Unknown") | ||||||
|         charging = true; |         status = _status; | ||||||
|       total += capacity; |       total += capacity; | ||||||
|     } |     } | ||||||
|     uint16_t capacity = total / _batteries.size(); |     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), |     _label.set_text(fmt::format(format, fmt::arg("capacity", capacity), | ||||||
|       fmt::arg("icon", _getIcon(capacity)))); |       fmt::arg("icon", _getIcon(capacity)))); | ||||||
|     _label.set_tooltip_text(status); |     _label.set_tooltip_text(status); | ||||||
|  |     bool charging = status == "Charging"; | ||||||
|     if (charging) |     if (charging) | ||||||
|       _label.get_style_context()->add_class("charging"); |       _label.get_style_context()->add_class("charging"); | ||||||
|     else |     else | ||||||
|  |  | ||||||
|  | @ -13,11 +13,11 @@ waybar::modules::sway::Workspaces::Workspaces(Bar &bar, Json::Value config) | ||||||
|   ipc_single_command(_ipcEventfd, IPC_SUBSCRIBE, subscribe, &len); |   ipc_single_command(_ipcEventfd, IPC_SUBSCRIBE, subscribe, &len); | ||||||
|   _thread = [this] { |   _thread = [this] { | ||||||
|     try { |     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()) |         while (_bar.outputName.empty()) | ||||||
|           _thread.sleep_for(chrono::milliseconds(150)); |           _thread.sleep_for(chrono::milliseconds(150)); | ||||||
|       } else |       } else if (_workspaces.size()) | ||||||
|         ipc_recv_response(_ipcEventfd); |         ipc_recv_response(_ipcEventfd); | ||||||
|       uint32_t len = 0; |       uint32_t len = 0; | ||||||
|       std::lock_guard<std::mutex> lock(_mutex); |       std::lock_guard<std::mutex> lock(_mutex); | ||||||
|  | @ -45,7 +45,8 @@ auto waybar::modules::sway::Workspaces::update() -> void | ||||||
|       ++it; |       ++it; | ||||||
|   } |   } | ||||||
|   for (auto node : _workspaces) { |   for (auto node : _workspaces) { | ||||||
|     if (_bar.outputName != node["output"].asString()) |     if (!_config["all-outputs"].asBool() | ||||||
|  |       && _bar.outputName != node["output"].asString()) | ||||||
|       continue; |       continue; | ||||||
|     auto it = _buttons.find(node["num"].asInt()); |     auto it = _buttons.find(node["num"].asInt()); | ||||||
|     if (it == _buttons.end()) { |     if (it == _buttons.end()) { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue