diff --git a/Cargo.lock b/Cargo.lock index 2b41c49..0019919 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -477,12 +477,6 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22" -[[package]] -name = "bit_field" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" - [[package]] name = "bitflags" version = "1.3.2" @@ -573,6 +567,12 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + [[package]] name = "bytes" version = "1.9.0" @@ -887,7 +887,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -905,7 +905,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "quote", "syn 1.0.109", @@ -943,6 +943,7 @@ name = "cosmic-settings-config" version = "0.1.0" dependencies = [ "cosmic-config", + "ron", "serde", "serde_with", "thiserror", @@ -1004,7 +1005,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "almost", "cosmic-config", @@ -1045,25 +1046,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "crossbeam-deque" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-utils" version = "0.8.21" @@ -1347,12 +1329,6 @@ dependencies = [ "linux-raw-sys 0.6.5", ] -[[package]] -name = "either" -version = "1.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" - [[package]] name = "endi" version = "1.1.0" @@ -1442,21 +1418,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "exr" -version = "1.73.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" -dependencies = [ - "bit_field", - "half", - "lebe", - "miniz_oxide", - "rayon-core", - "smallvec", - "zune-inflate", -] - [[package]] name = "fast-srgb8" version = "1.0.0" @@ -1980,7 +1941,7 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "dnd", "iced_accessibility", @@ -1998,7 +1959,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "accesskit", "accesskit_winit", @@ -2007,7 +1968,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "bitflags 2.7.0", "bytes", @@ -2031,7 +1992,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "futures", "iced_core", @@ -2056,7 +2017,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "bitflags 2.7.0", "bytemuck", @@ -2078,7 +2039,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2090,7 +2051,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "bytes", "dnd", @@ -2105,7 +2066,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "bytemuck", "cosmic-text", @@ -2121,7 +2082,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "as-raw-xcb-connection", "bitflags 2.7.0", @@ -2152,7 +2113,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "dnd", "iced_accessibility", @@ -2170,7 +2131,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "dnd", "iced_accessibility", @@ -2337,20 +2298,16 @@ dependencies = [ [[package]] name = "image" -version = "0.24.9" +version = "0.25.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5690139d2f55868e080017335e4b94cb7414274c74f1669c84fb5feba2c9f69d" +checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" dependencies = [ "bytemuck", - "byteorder", - "color_quant", - "exr", - "gif", - "jpeg-decoder", + "byteorder-lite", "num-traits", "png", - "qoi", - "tiff", + "zune-core", + "zune-jpeg", ] [[package]] @@ -2512,9 +2469,6 @@ name = "jpeg-decoder" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" -dependencies = [ - "rayon", -] [[package]] name = "js-sys" @@ -2607,12 +2561,6 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -[[package]] -name = "lebe" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" - [[package]] name = "libc" version = "0.2.169" @@ -2622,7 +2570,7 @@ checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#bd8347f7fcb8acad3bfd90cb0bc0891330db12e6" +source = "git+https://github.com/pop-os/libcosmic#fdfd80f8b133f3a1240a122489310146a224a7a7" dependencies = [ "apply", "chrono", @@ -2639,6 +2587,7 @@ dependencies = [ "iced_runtime", "iced_tiny_skia", "iced_widget", + "image", "lazy_static", "palette", "serde", @@ -3673,15 +3622,6 @@ version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" -[[package]] -name = "qoi" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" -dependencies = [ - "bytemuck", -] - [[package]] name = "quick-xml" version = "0.31.0" @@ -3757,26 +3697,6 @@ version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - [[package]] name = "read-fonts" version = "0.25.3" @@ -3858,14 +3778,15 @@ dependencies = [ [[package]] name = "ron" -version = "0.8.1" +version = "0.9.0-alpha.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91f7eff05f748767f183df4320a63d6936e9c6107d97c9e6bdd9784f4289c94" +checksum = "6c0bd893640cac34097a74f0c2389ddd54c62d6a3c635fa93cafe6b6bc19be6a" dependencies = [ "base64 0.21.7", "bitflags 2.7.0", "serde", "serde_derive", + "unicode-ident", ] [[package]] @@ -4396,17 +4317,6 @@ dependencies = [ "syn 2.0.96", ] -[[package]] -name = "tiff" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" -dependencies = [ - "flate2", - "jpeg-decoder", - "weezl", -] - [[package]] name = "time" version = "0.3.37" @@ -6005,12 +5915,18 @@ dependencies = [ ] [[package]] -name = "zune-inflate" -version = "0.2.54" +name = "zune-core" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-jpeg" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" dependencies = [ - "simd-adler32", + "zune-core", ] [[package]] diff --git a/config/Cargo.toml b/config/Cargo.toml index 4672439..0bef5ef 100644 --- a/config/Cargo.toml +++ b/config/Cargo.toml @@ -10,3 +10,4 @@ serde_with = "3.9.0" thiserror = "1.0.64" tracing = "0.1.40" xkbcommon = "0.7.0" +ron = "0.9.0-alpha.0" diff --git a/config/src/shortcuts/mod.rs b/config/src/shortcuts/mod.rs index f069855..15a0064 100644 --- a/config/src/shortcuts/mod.rs +++ b/config/src/shortcuts/mod.rs @@ -55,8 +55,8 @@ pub fn system_actions(context: &cosmic_config::Config) -> SystemActions { // Get the system config first if let Ok(context) = cosmic_config::Config::system(ID, Config::VERSION) { - match context.get::("system_actions") { - Ok(system_config) => config = system_config, + match context.get::("system_actions") { + Ok(system_config) => config = system_config.0, Err(why) => { tracing::error!("failed to read system shortcuts config 'system_actions': {why:?}"); } @@ -64,8 +64,8 @@ pub fn system_actions(context: &cosmic_config::Config) -> SystemActions { } // Then override it with the user's config - match context.get::("system_actions") { - Ok(user_config) => config.extend(user_config), + match context.get::("system_actions") { + Ok(user_config) => config.extend(user_config.0), Err(why) => { tracing::error!("failed to read local shortcuts config 'system_actions': {why:?}"); } @@ -100,10 +100,54 @@ impl Config { } /// A map of defined key [Binding]s and their triggerable [Action]s -#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)] +#[derive(Clone, Debug, Default, PartialEq, Serialize)] #[serde(transparent)] pub struct Shortcuts(pub HashMap); +struct ShortcutMapVisitor; + +impl<'de> serde::de::Visitor<'de> for ShortcutMapVisitor { + type Value = Shortcuts; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("Shortcuts Map") + } + + fn visit_map(self, mut access: M) -> Result + where + M: serde::de::MapAccess<'de>, + { + let mut map = HashMap::with_capacity(access.size_hint().unwrap_or(0)); + + while let Some((binding, action)) = access.next_entry::()? { + match action.into_rust::() { + Ok(val) => { + map.insert(binding, val); + } + Err(err) => { + tracing::warn!( + "Skipping over invalid Action ({}): {}", + action.get_ron(), + err + ); + map.insert(binding, Action::Disable); + } + }; + } + + Ok(Shortcuts(map)) + } +} + +impl<'de> Deserialize<'de> for Shortcuts { + fn deserialize(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + deserializer.deserialize_map(ShortcutMapVisitor) + } +} + impl Shortcuts { // pub fn default_shortcuts() -> Self { // Shortcuts(HashMap::from([ @@ -172,3 +216,48 @@ pub enum State { Pressed, Released, } + +pub struct SystemActionsImpl(SystemActions); + +struct SystemActionsMapVisitor; + +impl<'de> serde::de::Visitor<'de> for SystemActionsMapVisitor { + type Value = SystemActionsImpl; + + fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result { + formatter.write_str("SystemActions Map") + } + + fn visit_map(self, mut access: M) -> Result + where + M: serde::de::MapAccess<'de>, + { + let mut map = BTreeMap::new(); + + while let Some((action, command)) = access.next_entry::<&ron::value::RawValue, String>()? { + match action.into_rust::() { + Ok(val) => { + map.insert(val, command); + } + Err(err) => { + tracing::warn!( + "Skipping over invalid SystemAction ({}): {}", + action.get_ron(), + err + ); + } + }; + } + + Ok(SystemActionsImpl(map)) + } +} + +impl<'de> Deserialize<'de> for SystemActionsImpl { + fn deserialize(deserializer: D) -> Result + where + D: serde::de::Deserializer<'de>, + { + deserializer.deserialize_map(SystemActionsMapVisitor) + } +}