diff --git a/Cargo.lock b/Cargo.lock index 8fc307c..57b6e88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1092,9 +1092,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hyprland" -version = "0.3.0-alpha.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04a666b11a405dd7d74dbfb915e7d6f09bc0a52b0715204bf2e54d5572ab935" +checksum = "0f76d4dad14a688266c346a9233e8cc5cea0c31a489d8811e3d93176338bafc0" dependencies = [ "async-trait", "doc-comment", @@ -1106,6 +1106,8 @@ dependencies = [ "serde", "serde_json", "serde_repr", + "strum", + "strum_macros", "tokio", ] @@ -1213,7 +1215,7 @@ dependencies = [ "swayipc-async", "sysinfo", "tokio", - "toml", + "toml 0.7.0", "tracing", "tracing-appender", "tracing-error", @@ -1280,7 +1282,7 @@ dependencies = [ "pest", "pest_derive", "serde", - "toml", + "toml 0.5.9", ] [[package]] @@ -1485,6 +1487,15 @@ dependencies = [ "minimal-lexical", ] +[[package]] +name = "nom8" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8" +dependencies = [ + "memchr", +] + [[package]] name = "notify" version = "5.0.0" @@ -1737,7 +1748,7 @@ checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" dependencies = [ "once_cell", "thiserror", - "toml", + "toml 0.5.9", ] [[package]] @@ -1910,6 +1921,12 @@ dependencies = [ "semver", ] +[[package]] +name = "rustversion" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + [[package]] name = "ryu" version = "1.0.11" @@ -1997,6 +2014,15 @@ dependencies = [ "syn 1.0.105", ] +[[package]] +name = "serde_spanned" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c68e921cef53841b8925c2abadd27c9b891d9613bdc43d6b823062866df38e8" +dependencies = [ + "serde", +] + [[package]] name = "serde_yaml" version = "0.9.14" @@ -2146,6 +2172,25 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.0", + "proc-macro2", + "quote 1.0.21", + "rustversion", + "syn 1.0.105", +] + [[package]] name = "swayipc-async" version = "2.0.1" @@ -2226,7 +2271,7 @@ dependencies = [ "cfg-expr", "heck 0.4.0", "pkg-config", - "toml", + "toml 0.5.9", "version-compare", ] @@ -2371,6 +2416,40 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f560bc7fb3eb31f5eee1340c68a2160cad39605b7b9c9ec32045ddbdee13b85" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886f31a9b85b6182cabd4d8b07df3b451afcc216563748201490940d2a28ed36" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233d8716cdc5d20ec88a18a839edaf545edc71efa4a5ff700ef4a102c26cd8fa" +dependencies = [ + "indexmap", + "nom8", + "serde", + "serde_spanned", + "toml_datetime", +] + [[package]] name = "tracing" version = "0.1.37" diff --git a/Cargo.toml b/Cargo.toml index 1842639..167aaaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ color-eyre = "0.6.2" serde = { version = "1.0.141", features = ["derive"] } serde_json = "1.0.82" serde_yaml = "0.9.4" -toml = "0.5.9" +toml = "0.7.0" libcorn = "0.6.1" lazy_static = "1.4.0" async_once = "0.2.6" @@ -34,7 +34,7 @@ notify = { version = "5.0.0", default-features = false } mpd_client = "1.0.0" mpris = "2.0.0" swayipc-async = { version = "2.0.1" } -hyprland = "0.3.0-alpha.0" +hyprland = "0.3.0" sysinfo = "0.27.0" wayland-client = "0.29.5" wayland-protocols = { version = "0.29.5", features = ["unstable_protocols", "client"] } diff --git a/src/clients/compositor/hyprland.rs b/src/clients/compositor/hyprland.rs index 6c0705d..5eaa51a 100644 --- a/src/clients/compositor/hyprland.rs +++ b/src/clients/compositor/hyprland.rs @@ -164,8 +164,6 @@ impl EventClient { let active = HWorkspace::get_active().expect("Failed to get active workspace"); let new_workspaces = Workspaces::get() .expect("Failed to get workspaces") - .collect() - .into_iter() .map(|workspace| Workspace::from((workspace.id == active.id, workspace))); workspaces.clear(); @@ -232,8 +230,7 @@ pub fn get_client() -> &'static EventClient { fn id_to_string(id: WorkspaceType) -> String { match id { - WorkspaceType::Unnamed(id) => id.to_string(), - WorkspaceType::Named(name) => name, + WorkspaceType::Regular(name) => name, WorkspaceType::Special(name) => name.unwrap_or_default(), } } @@ -241,7 +238,7 @@ fn id_to_string(id: WorkspaceType) -> String { impl From<(bool, hyprland::data::Workspace)> for Workspace { fn from((focused, workspace): (bool, hyprland::data::Workspace)) -> Self { Self { - id: id_to_string(workspace.id), + id: workspace.id.to_string(), name: workspace.name, monitor: workspace.monitor, focused, diff --git a/src/config/impl.rs b/src/config/impl.rs index e1e560d..5018865 100644 --- a/src/config/impl.rs +++ b/src/config/impl.rs @@ -123,6 +123,9 @@ impl Config { /// and parses it into `Self` based on its extension. fn load_file(path: &Path) -> Result { let file = fs::read(path).wrap_err("Failed to read config file")?; + + let str = std::str::from_utf8(&file)?; + let extension = path .extension() .unwrap_or_default() @@ -130,10 +133,10 @@ impl Config { .unwrap_or_default(); match extension { - "json" => serde_json::from_slice(&file).wrap_err("Invalid JSON config"), - "toml" => toml::from_slice(&file).wrap_err("Invalid TOML config"), - "yaml" | "yml" => serde_yaml::from_slice(&file).wrap_err("Invalid YAML config"), - "corn" => libcorn::from_slice(&file).wrap_err("Invalid Corn config"), + "json" => serde_json::from_str(str).wrap_err("Invalid JSON config"), + "toml" => toml::from_str(str).wrap_err("Invalid TOML config"), + "yaml" | "yml" => serde_yaml::from_str(str).wrap_err("Invalid YAML config"), + "corn" => libcorn::from_str(str).wrap_err("Invalid Corn config"), _ => unreachable!(), } }