From ed238a33f778c3fcf515bf019c203435070e1b59 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 25 Jul 2024 14:17:54 -0700 Subject: [PATCH] Update for `spawn_desktop_exec` that calls `SpawnTransientUnit` Allows `xdg-desktop-portal` to get app id from PID. --- Cargo.lock | 209 ++++++++++++++++++++++++++++++++--------------------- Cargo.toml | 3 +- src/app.rs | 11 +-- 3 files changed, 136 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65cb904..b618f9c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -102,9 +102,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -117,33 +117,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -701,9 +701,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.10" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6b81fb3c84f5563d509c59b5a48d935f689e993afa90fe39047f05adef9142" +checksum = "35723e6a11662c2afb578bcf0b88bf6ea8e21282a953428f240574fcc3a2b5b3" dependencies = [ "clap_builder", "clap_derive", @@ -711,9 +711,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.10" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca6706fd5224857d9ac5eb9355f6683563cc0541c7cd9d014043b57cbec78ac" +checksum = "49eb96cbfa7cfa35017b7cd548c75b14c3118c98b423041d70562665e07fb0fa" dependencies = [ "anstream", "anstyle", @@ -723,9 +723,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "5d029b67f89d30bbb547c89fd5161293c0aec155fc691d7924b64550662db93e" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -735,9 +735,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clipboard-win" @@ -825,9 +825,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "com" @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "cosmic-app-list-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-applets#c6291c7c093e78dc21c3854a988b04db62106d6b" +source = "git+https://github.com/pop-os/cosmic-applets#478bb3e500ab1d9e7cbaa1d4d7695d137fbeac8c" dependencies = [ "libcosmic", "serde", @@ -984,14 +984,14 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "atomicwrites", - "cosmic-config-derive", + "cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "cosmic-settings-daemon", "dirs 5.0.1", "futures-util", - "iced_futures", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "known-folders", "notify", "once_cell", @@ -1003,6 +1003,33 @@ dependencies = [ "zbus 4.4.0", ] +[[package]] +name = "cosmic-config" +version = "0.1.0" +source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +dependencies = [ + "atomicwrites", + "cosmic-config-derive 0.1.0 (git+https://github.com/pop-os/libcosmic/)", + "dirs 5.0.1", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic/)", + "known-folders", + "notify", + "once_cell", + "ron", + "serde", + "tracing", + "xdg", +] + +[[package]] +name = "cosmic-config-derive" +version = "0.1.0" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" +dependencies = [ + "quote", + "syn 1.0.109", +] + [[package]] name = "cosmic-config-derive" version = "0.1.0" @@ -1015,10 +1042,10 @@ dependencies = [ [[package]] name = "cosmic-panel-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-panel#1d0e48f7d418a661c9eeca2802529e4606d349ff" +source = "git+https://github.com/pop-os/cosmic-panel#4958f0670653f8d896fcadd9e3a0fa446df15d95" dependencies = [ "anyhow", - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic/)", "ron", "serde", "smithay-client-toolkit", @@ -1074,10 +1101,10 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "almost", - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "csscolorparser", "dirs 5.0.1", "lazy_static", @@ -2231,7 +2258,7 @@ dependencies = [ "serde", "serde_derive", "thiserror", - "toml 0.8.15", + "toml 0.8.16", "unic-langid", ] @@ -2317,12 +2344,12 @@ dependencies = [ [[package]] name = "iced" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "dnd", "iced_accessibility", - "iced_core", - "iced_futures", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "iced_renderer", "iced_sctk", "iced_widget", @@ -2335,7 +2362,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "accesskit", "accesskit_unix", @@ -2344,7 +2371,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "bitflags 2.6.0", "dnd", @@ -2364,12 +2391,30 @@ dependencies = [ ] [[package]] -name = "iced_futures" +name = "iced_core" version = "0.12.0" source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +dependencies = [ + "bitflags 2.6.0", + "dnd", + "log", + "mime 0.1.0", + "num-traits", + "raw-window-handle", + "smol_str", + "thiserror", + "web-time", + "window_clipboard", + "xxhash-rust", +] + +[[package]] +name = "iced_futures" +version = "0.12.0" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "futures", - "iced_core", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "log", "tokio", "wasm-bindgen-futures", @@ -2377,17 +2422,29 @@ dependencies = [ ] [[package]] -name = "iced_graphics" +name = "iced_futures" version = "0.12.0" source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +dependencies = [ + "futures", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic/)", + "log", + "wasm-bindgen-futures", + "wasm-timer", +] + +[[package]] +name = "iced_graphics" +version = "0.12.0" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "bitflags 2.6.0", "bytemuck", "cosmic-text", "glam", "half", - "iced_core", - "iced_futures", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "image", "kamadak-exif", "log", @@ -2403,7 +2460,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2415,12 +2472,12 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "dnd", "iced_accessibility", - "iced_core", - "iced_futures", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "smithay-client-toolkit", "thiserror", "window_clipboard", @@ -2429,12 +2486,12 @@ dependencies = [ [[package]] name = "iced_sctk" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "enum-repr", "float-cmp", "futures", - "iced_futures", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "iced_graphics", "iced_runtime", "iced_style", @@ -2455,9 +2512,9 @@ dependencies = [ [[package]] name = "iced_style" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ - "iced_core", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "once_cell", "palette", ] @@ -2465,7 +2522,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "bytemuck", "cosmic-text", @@ -2482,7 +2539,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -2511,7 +2568,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.12.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "dnd", "iced_renderer", @@ -2653,9 +2710,9 @@ dependencies = [ [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -2784,13 +2841,13 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic/#a5996b4e90f6aad943b7c61b961fae5edacd7697" +source = "git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit#fd0e54747976c383f02212a753a2b0bde06af6c5" dependencies = [ "apply", "ashpd", "chrono", "cosmic-client-toolkit", - "cosmic-config", + "cosmic-config 0.1.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "cosmic-panel-config", "cosmic-settings-daemon", "cosmic-theme", @@ -2800,8 +2857,8 @@ dependencies = [ "freedesktop-desktop-entry", "freedesktop-icons", "iced", - "iced_core", - "iced_futures", + "iced_core 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", + "iced_futures 0.12.0 (git+https://github.com/pop-os/libcosmic//?branch=start-transient-unit)", "iced_renderer", "iced_runtime", "iced_sctk", @@ -2810,11 +2867,12 @@ dependencies = [ "iced_wgpu", "iced_widget", "lazy_static", + "libc", "mime 0.3.17", - "nix 0.27.1", "palette", "rfd", "ron", + "rustix 0.38.34", "serde", "shlex", "slotmap", @@ -3124,17 +3182,6 @@ dependencies = [ "memoffset 0.7.1", ] -[[package]] -name = "nix" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" -dependencies = [ - "bitflags 2.6.0", - "cfg-if", - "libc", -] - [[package]] name = "nix" version = "0.28.0" @@ -4119,9 +4166,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -4625,21 +4672,21 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "81967dd0dd2c1ab0bc3468bd7caecc32b8a4aa47d0c8c695d8c2b2108168d62c" dependencies = [ "serde", "serde_spanned", "toml_datetime", - "toml_edit 0.22.16", + "toml_edit 0.22.17", ] [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "f8fb9f64314842840f1d940ac544da178732128f1c78c21772e876579e0da1db" dependencies = [ "serde", ] @@ -4668,15 +4715,15 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "8d9f8729f5aea9562aac1cc0441f5d6de3cff1ee0c5d67293eeca5eb36ee7c16" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", - "winnow 0.6.15", + "winnow 0.6.16", ] [[package]] @@ -5521,9 +5568,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.6.15" +version = "0.6.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "557404e450152cd6795bb558bca69e43c585055f4606e3bcae5894fc6dac9ba0" +checksum = "b480ae9340fc261e6be3e95a1ba86d54ae3f9171132a73ce8d4bbaf68339507c" dependencies = [ "memchr", ] @@ -5574,7 +5621,7 @@ dependencies = [ [[package]] name = "xdg-shell-wrapper-config" version = "0.1.0" -source = "git+https://github.com/pop-os/cosmic-panel#1d0e48f7d418a661c9eeca2802529e4606d349ff" +source = "git+https://github.com/pop-os/cosmic-panel#4958f0670653f8d896fcadd9e3a0fa446df15d95" dependencies = [ "serde", "wayland-protocols-wlr", diff --git a/Cargo.toml b/Cargo.toml index 8f7e746..994c869 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,7 @@ cosmic-app-list-config = { git = "https://github.com/pop-os/cosmic-applets" } [profile.release] lto = "thin" -# [patch."https://github.com/pop-os/libcosmic"] +[patch."https://github.com/pop-os/libcosmic"] # cosmic-config = { path = "../libcosmic/cosmic-config/" } # libcosmic = { path = "../libcosmic/" } +libcosmic = { git = "https://github.com/pop-os/libcosmic//", branch = "start-transient-unit" } diff --git a/src/app.rs b/src/app.rs index 5cedbe6..0bc4482 100644 --- a/src/app.rs +++ b/src/app.rs @@ -255,7 +255,7 @@ enum Message { Layer(LayerEvent, SurfaceId), Hide, ActivateApp(usize, Option), - ActivationToken(Option, String, Option), + ActivationToken(Option, String, String, Option), SelectGroup(usize), Delete(usize), ConfirmDelete, @@ -460,19 +460,20 @@ impl cosmic::Application for CosmicAppLibrary { Message::ActivateApp(i, gpu_idx) => { self.edit_name = None; if let Some(de) = self.entry_path_input.get(i) { + let app_id = de.id.clone(); let exec = de.exec.clone().unwrap(); return request_token( Some(String::from(Self::APP_ID)), Some(WINDOW_ID.clone()), move |token| { cosmic::app::Message::App(Message::ActivationToken( - token, exec, gpu_idx, + token, app_id, exec, gpu_idx, )) }, ); } } - Message::ActivationToken(token, exec, gpu_idx) => { + Message::ActivationToken(token, app_id, exec, gpu_idx) => { let mut env_vars = Vec::new(); if let Some(token) = token { env_vars.push(("XDG_ACTIVATION_TOKEN".to_string(), token.clone())); @@ -481,8 +482,8 @@ impl cosmic::Application for CosmicAppLibrary { if let (Some(gpus), Some(idx)) = (self.gpus.as_ref(), gpu_idx) { env_vars.extend(gpus[idx].environment.clone().into_iter()); } - tokio::task::spawn_blocking(move || { - cosmic::desktop::spawn_desktop_exec(exec, env_vars) + tokio::spawn(async move { + cosmic::desktop::spawn_desktop_exec(exec, env_vars, Some(&app_id)).await }); return self.update(Message::Hide); }