diff --git a/Cargo.lock b/Cargo.lock index 2616dcfb..b0a4a3b9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -221,15 +221,15 @@ dependencies = [ [[package]] name = "async-executor" -version = "1.6.0" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" +checksum = "fc5ea910c42e5ab19012bab31f53cb4d63d54c3a27730f9a833a88efcf4bb52d" dependencies = [ - "async-lock 2.8.0", + "async-lock 3.1.1", "async-task", "concurrent-queue", "fastrand 2.0.1", - "futures-lite 1.13.0", + "futures-lite 2.0.1", "slab", ] @@ -271,14 +271,14 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" dependencies = [ - "async-lock 3.1.0", + "async-lock 3.1.1", "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.0.1", "parking", "polling 3.3.0", - "rustix 0.38.24", + "rustix 0.38.25", "slab", "tracing", "waker-fn", @@ -296,9 +296,9 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.1.0" +version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" +checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105" dependencies = [ "event-listener 3.1.0", "event-listener-strategy", @@ -318,7 +318,7 @@ dependencies = [ "cfg-if", "event-listener 3.1.0", "futures-lite 1.13.0", - "rustix 0.38.24", + "rustix 0.38.25", "windows-sys", ] @@ -345,7 +345,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 0.38.24", + "rustix 0.38.25", "signal-hook-registry", "slab", "windows-sys", @@ -379,7 +379,7 @@ name = "atomicwrites" version = "0.4.2" source = "git+https://github.com/jackpot51/rust-atomicwrites#043ab4859d53ffd3d55334685303d8df39c9f768" dependencies = [ - "rustix 0.38.24", + "rustix 0.38.25", "tempfile", "windows-sys", ] @@ -507,7 +507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" dependencies = [ "async-channel 2.1.0", - "async-lock 3.1.0", + "async-lock 3.1.1", "async-task", "fastrand 2.0.1", "futures-io", @@ -592,7 +592,7 @@ dependencies = [ "bitflags 2.4.1", "log", "polling 3.3.0", - "rustix 0.38.24", + "rustix 0.38.25", "slab", "thiserror", ] @@ -604,7 +604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" dependencies = [ "calloop", - "rustix 0.38.24", + "rustix 0.38.25", "wayland-backend 0.3.2", "wayland-client 0.31.1", ] @@ -959,6 +959,7 @@ dependencies = [ "nix 0.26.4", "once_cell", "rust-embed 6.8.1", + "tracing", ] [[package]] @@ -993,7 +994,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "atomicwrites", "cosmic-config-derive", @@ -1007,7 +1008,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "quote", "syn 1.0.109", @@ -1107,7 +1108,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "almost", "cosmic-config", @@ -1662,9 +1663,9 @@ dependencies = [ [[package]] name = "etagere" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf22f748754352918e082e0039335ee92454a5d62bcaf69b5e8daf5907d9644" +checksum = "306960881d6c46bd0dd6b7f07442a441418c08d0d3e63d8d080b0f64c6343e4e" dependencies = [ "euclid", "svg_fmt", @@ -2060,7 +2061,11 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" dependencies = [ + "fastrand 2.0.1", "futures-core", + "futures-io", + "memchr", + "parking", "pin-project-lite", ] @@ -2560,7 +2565,7 @@ dependencies = [ [[package]] name = "iced" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_accessibility", "iced_core", @@ -2575,7 +2580,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "accesskit", "accesskit_unix", @@ -2584,7 +2589,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.10.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bitflags 1.3.2", "iced_accessibility", @@ -2600,7 +2605,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.7.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "futures", "iced_core", @@ -2613,7 +2618,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2631,7 +2636,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2644,7 +2649,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.1.1" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_accessibility", "iced_core", @@ -2656,7 +2661,7 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "enum-repr", "float-cmp", @@ -2680,7 +2685,7 @@ dependencies = [ [[package]] name = "iced_style" version = "0.9.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_core", "once_cell", @@ -2690,7 +2695,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bytemuck", "cosmic-text", @@ -2708,7 +2713,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.11.1" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "bitflags 1.3.2", "bytemuck", @@ -2730,7 +2735,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.1.3" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "iced_renderer", "iced_runtime", @@ -2886,7 +2891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi 0.3.3", - "rustix 0.38.24", + "rustix 0.38.25", "windows-sys", ] @@ -3002,10 +3007,11 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" +source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f" dependencies = [ "apply", "ashpd", + "cosmic-client-toolkit", "cosmic-config", "cosmic-panel-config", "cosmic-theme", @@ -3023,16 +3029,17 @@ dependencies = [ "iced_tiny_skia", "iced_widget", "lazy_static", + "nix 0.26.4", "palette", "ron", "slotmap", - "smithay-client-toolkit 0.18.0", "taffy", "thiserror", "tokio", "tracing", "unicode-segmentation", "url", + "zbus", ] [[package]] @@ -3203,9 +3210,9 @@ dependencies = [ [[package]] name = "lyon_algorithms" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00a0349cd8f0270781bb93a824b63df6178e3b4a27794e7be3ce3763f5a44d6e" +checksum = "a3bca95f9a4955b3e4a821fbbcd5edfbd9be2a9a50bb5758173e5358bfb4c623" dependencies = [ "lyon_path", "num-traits", @@ -3918,7 +3925,7 @@ dependencies = [ "cfg-if", "concurrent-queue", "pin-project-lite", - "rustix 0.38.24", + "rustix 0.38.25", "tracing", "windows-sys", ] @@ -4017,7 +4024,7 @@ dependencies = [ "hex", "lazy_static", "procfs-core", - "rustix 0.38.24", + "rustix 0.38.25", ] [[package]] @@ -4378,9 +4385,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.24" +version = "0.38.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" +checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" dependencies = [ "bitflags 2.4.1", "errno", @@ -4482,18 +4489,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -4654,7 +4661,7 @@ dependencies = [ "log", "memmap2 0.9.0", "pkg-config", - "rustix 0.38.24", + "rustix 0.38.25", "thiserror", "wayland-backend 0.3.2", "wayland-client 0.31.1", @@ -4716,7 +4723,7 @@ dependencies = [ "objc", "raw-window-handle", "redox_syscall 0.4.1", - "rustix 0.38.24", + "rustix 0.38.25", "tiny-xlib", "wasm-bindgen", "wayland-backend 0.3.2", @@ -4874,7 +4881,7 @@ dependencies = [ [[package]] name = "taffy" version = "0.3.11" -source = "git+https://github.com/DioxusLabs/taffy#1876f72bee5e376023eaa518aa7b8a34c769bd1b" +source = "git+https://github.com/DioxusLabs/taffy#70b35712a2e79b6fdfef4cff4392ca94287cd0b1" dependencies = [ "arrayvec", "grid", @@ -4903,7 +4910,7 @@ dependencies = [ "cfg-if", "fastrand 2.0.1", "redox_syscall 0.4.1", - "rustix 0.38.24", + "rustix 0.38.25", "windows-sys", ] @@ -5025,9 +5032,9 @@ dependencies = [ [[package]] name = "tinystr" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0e245e80bdc9b4e5356fc45a72184abbc3861992603f515270e9340f5a219" +checksum = "83c02bf3c538ab32ba913408224323915f4ef9a6d61c0e85d493f355921c0ece" dependencies = [ "displaydoc", ] @@ -5428,9 +5435,9 @@ dependencies = [ [[package]] name = "uuid" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", ] diff --git a/Cargo.toml b/Cargo.toml index a2b9bb0f..443e79ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,11 +29,13 @@ cosmic-time = { git = "https://github.com/pop-os/cosmic-time", default-features ] } libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [ "applet", + "applet-token", "tokio", "wayland", + "process", ] } zbus = { version = "3.14", default-features = false, features = ["tokio"] } - +tracing = "0.1" [profile.release] lto = "thin" diff --git a/cosmic-applet-time/Cargo.toml b/cosmic-applet-time/Cargo.toml index f20e3339..23bb7477 100644 --- a/cosmic-applet-time/Cargo.toml +++ b/cosmic-applet-time/Cargo.toml @@ -10,7 +10,9 @@ libcosmic.workspace = true nix = "0.26.2" chrono = { version = "0.4.23", features = ["clock"] } once_cell = "1" +tracing.workspace = true + # Application i18n i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] } i18n-embed-fl = "0.6.4" -rust-embed = "6.3.0" \ No newline at end of file +rust-embed = "6.3.0" diff --git a/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop b/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop index a0f1a4ce..8a4a8287 100644 --- a/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop +++ b/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop @@ -9,3 +9,5 @@ Keywords=Cosmic;Iced; Icon=com.system76.CosmicAppletTime NoDisplay=true X-CosmicApplet=true +X-HostWaylandDisplay=true + diff --git a/cosmic-applet-time/src/window.rs b/cosmic-applet-time/src/window.rs index edff6b1a..b4aeccb8 100644 --- a/cosmic-applet-time/src/window.rs +++ b/cosmic-applet-time/src/window.rs @@ -1,4 +1,5 @@ use cosmic::applet::{menu_button, padded_control}; +use cosmic::cctk::sctk::reexports::calloop; use cosmic::iced::wayland::popup::{destroy_popup, get_popup}; use cosmic::iced::{ time, @@ -19,6 +20,9 @@ use std::time::Duration; use crate::fl; use crate::time::get_calender_first; +use cosmic::applet::token::subscription::{ + activation_token_subscription, TokenRequest, TokenUpdate, +}; #[derive(Debug, Clone)] #[allow(dead_code)] @@ -35,6 +39,7 @@ pub struct Window { now: DateTime, rectangle_tracker: Option>, rectangle: Rectangle, + token_tx: Option>, } #[derive(Debug, Clone)] @@ -47,6 +52,7 @@ pub enum Message { PreviousMonth, NextMonth, OpenDateTimeSettings, + Token(TokenUpdate), } impl cosmic::Application for Window { @@ -68,6 +74,7 @@ impl cosmic::Application for Window { now: Local::now(), rectangle_tracker: None, rectangle: Rectangle::default(), + token_tx: None, }, Command::none(), ) @@ -106,6 +113,7 @@ impl cosmic::Application for Window { wait.try_into().unwrap_or(FALLBACK_DELAY), )) .map(|_| Message::Tick), + activation_token_subscription(0).map(Message::Token), ]) } @@ -178,7 +186,35 @@ impl cosmic::Application for Window { Command::none() } Message::OpenDateTimeSettings => { - // TODO + let exec = "cosmic-settings time".to_string(); + if let Some(tx) = self.token_tx.as_ref() { + let _ = tx.send(TokenRequest { + app_id: Self::APP_ID.to_string(), + exec, + }); + } else { + tracing::error!("Wayland tx is None"); + }; + Command::none() + } + Message::Token(u) => { + match u { + TokenUpdate::Init(tx) => { + self.token_tx = Some(tx); + } + TokenUpdate::Finished => { + self.token_tx = None; + } + TokenUpdate::ActivationToken { token, .. } => { + let mut cmd = std::process::Command::new("cosmic-settings"); + cmd.arg("time"); + if let Some(token) = token { + cmd.env("XDG_ACTIVATION_TOKEN", &token); + cmd.env("DESKTOP_STARTUP_ID", &token); + } + cosmic::process::spawn(cmd); + } + } Command::none() } }