Skip to content

Commit a62cb5f

Browse files
committed
fix: fix reading workspaces failing with komorebi v0.1.36
This due to failure to serialize komorebi state because of type changes in LGUG2Z/komorebi@5cc688d#diff-63b9ef3c0015218cc22dbadfbfd4e631fea784714f05a4c4047af3d99ade667dL65-R121
1 parent 9d61c4d commit a62cb5f

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Fixed reading workspaces failing with komorebi v0.1.36
8+
59
## [0.6.1] - 2025-04-08
610

711
### Changed

src/komorebi.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,29 @@ use winit::event_loop::EventLoopProxy;
1111

1212
use crate::app::AppMessage;
1313

14+
#[derive(Debug, Deserialize)]
15+
#[serde(untagged)]
16+
enum MaybeRingOrVec<T> {
17+
Ring(Ring<T>),
18+
Vec(Vec<T>),
19+
}
20+
21+
impl<T> MaybeRingOrVec<T> {
22+
fn is_empty(&self) -> bool {
23+
match self {
24+
MaybeRingOrVec::Ring(ring) => ring.is_empty(),
25+
MaybeRingOrVec::Vec(vec) => vec.is_empty(),
26+
}
27+
}
28+
}
29+
1430
#[derive(Debug, Deserialize)]
1531
struct KWorkspace {
1632
name: Option<String>,
1733
containers: Ring<serde_json::Value>,
1834
maximized_window: Option<serde_json::Value>,
1935
monocle_container: Option<serde_json::Value>,
20-
floating_windows: Vec<serde_json::Value>,
36+
floating_windows: MaybeRingOrVec<serde_json::Value>,
2137
}
2238

2339
impl KWorkspace {

src/main_window.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ impl MainWindowView {
9494
proxy: EventLoopProxy<AppMessage>,
9595
window_info: WindowRegistryInfo,
9696
) -> anyhow::Result<Self> {
97-
let workspaces = crate::komorebi::read_workspaces().unwrap_or_default();
97+
let workspaces = crate::komorebi::read_workspaces()
98+
.inspect_err(|e| {
99+
tracing::error!("Failed to read workspaces: {e}");
100+
})
101+
.unwrap_or_default();
98102

99103
let mut view = Self {
100104
window,

0 commit comments

Comments
 (0)