diff options
| author | Florian Straubinger <github@f-str.de> | 2024-10-06 10:32:37 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-06 11:32:37 +0300 |
| commit | 778e88432d06c492a6611c8ed1464a423f67551a (patch) | |
| tree | e908e9c4fc16ab7d0e7e6151a0b62c7b07c8d32d /src | |
| parent | 1bf110c7bcfdc07b2a946837aee25a4f0c2340fb (diff) | |
| download | i3bar-mango-778e88432d06c492a6611c8ed1464a423f67551a.tar.gz | |
hyprland: Fixed active workspace selection with named workspaces (#36)
Diffstat (limited to 'src')
| -rw-r--r-- | src/wm_info_provider/hyprland.rs | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/wm_info_provider/hyprland.rs b/src/wm_info_provider/hyprland.rs index a59a68f..0d7d4ec 100644 --- a/src/wm_info_provider/hyprland.rs +++ b/src/wm_info_provider/hyprland.rs @@ -114,18 +114,28 @@ fn hyprland_cb(conn: &mut Connection<State>, state: &mut State) -> io::Result<() match hyprland.ipc.next_event() { Ok(event) => { if let Some(active_ws) = event.strip_prefix("workspace>>") { - hyprland.active_id = active_ws - .parse() - .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + let ws = hyprland + .workspaces + .iter() + .find(|ws| ws.name == active_ws) + .ok_or_else(|| { + io::Error::new(io::ErrorKind::InvalidData, "Unknown workspace") + })?; + hyprland.active_id = ws.id; updated = true; } else if let Some(data) = event.strip_prefix("focusedmon>>") { let (_monitor, active_ws) = data.split_once(',').ok_or_else(|| { io::Error::new(io::ErrorKind::InvalidData, "Too few fields in data") })?; - hyprland.active_id = active_ws - .parse() - .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?; + let ws = hyprland + .workspaces + .iter() + .find(|ws| ws.name == active_ws) + .ok_or_else(|| { + io::Error::new(io::ErrorKind::InvalidData, "Unknown workspace") + })?; + hyprland.active_id = ws.id; updated = true; } else if event.contains("workspace>>") { hyprland.workspaces = hyprland.ipc.query_sorted_workspaces()?; |
