chore: open settings when time settings is pressed

This commit is contained in:
Ashley Wulber 2023-11-21 17:29:49 -05:00 committed by Ashley Wulber
parent aa2d9fe374
commit f5c51ecc92
5 changed files with 104 additions and 55 deletions

111
Cargo.lock generated
View file

@ -221,15 +221,15 @@ dependencies = [
[[package]] [[package]]
name = "async-executor" name = "async-executor"
version = "1.6.0" version = "1.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4b0c4a4f319e45986f347ee47fef8bf5e81c9abc3f6f58dc2391439f30df65f0" checksum = "fc5ea910c42e5ab19012bab31f53cb4d63d54c3a27730f9a833a88efcf4bb52d"
dependencies = [ dependencies = [
"async-lock 2.8.0", "async-lock 3.1.1",
"async-task", "async-task",
"concurrent-queue", "concurrent-queue",
"fastrand 2.0.1", "fastrand 2.0.1",
"futures-lite 1.13.0", "futures-lite 2.0.1",
"slab", "slab",
] ]
@ -271,14 +271,14 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997" checksum = "41ed9d5715c2d329bf1b4da8d60455b99b187f27ba726df2883799af9af60997"
dependencies = [ dependencies = [
"async-lock 3.1.0", "async-lock 3.1.1",
"cfg-if", "cfg-if",
"concurrent-queue", "concurrent-queue",
"futures-io", "futures-io",
"futures-lite 2.0.1", "futures-lite 2.0.1",
"parking", "parking",
"polling 3.3.0", "polling 3.3.0",
"rustix 0.38.24", "rustix 0.38.25",
"slab", "slab",
"tracing", "tracing",
"waker-fn", "waker-fn",
@ -296,9 +296,9 @@ dependencies = [
[[package]] [[package]]
name = "async-lock" name = "async-lock"
version = "3.1.0" version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb2ab2aa8a746e221ab826c73f48bc6ba41be6763f0855cb249eb6d154cf1d7" checksum = "655b9c7fe787d3b25cc0f804a1a8401790f0c5bc395beb5a64dc77d8de079105"
dependencies = [ dependencies = [
"event-listener 3.1.0", "event-listener 3.1.0",
"event-listener-strategy", "event-listener-strategy",
@ -318,7 +318,7 @@ dependencies = [
"cfg-if", "cfg-if",
"event-listener 3.1.0", "event-listener 3.1.0",
"futures-lite 1.13.0", "futures-lite 1.13.0",
"rustix 0.38.24", "rustix 0.38.25",
"windows-sys", "windows-sys",
] ]
@ -345,7 +345,7 @@ dependencies = [
"cfg-if", "cfg-if",
"futures-core", "futures-core",
"futures-io", "futures-io",
"rustix 0.38.24", "rustix 0.38.25",
"signal-hook-registry", "signal-hook-registry",
"slab", "slab",
"windows-sys", "windows-sys",
@ -379,7 +379,7 @@ name = "atomicwrites"
version = "0.4.2" version = "0.4.2"
source = "git+https://github.com/jackpot51/rust-atomicwrites#043ab4859d53ffd3d55334685303d8df39c9f768" source = "git+https://github.com/jackpot51/rust-atomicwrites#043ab4859d53ffd3d55334685303d8df39c9f768"
dependencies = [ dependencies = [
"rustix 0.38.24", "rustix 0.38.25",
"tempfile", "tempfile",
"windows-sys", "windows-sys",
] ]
@ -507,7 +507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118" checksum = "6a37913e8dc4ddcc604f0c6d3bf2887c995153af3611de9e23c352b44c1b9118"
dependencies = [ dependencies = [
"async-channel 2.1.0", "async-channel 2.1.0",
"async-lock 3.1.0", "async-lock 3.1.1",
"async-task", "async-task",
"fastrand 2.0.1", "fastrand 2.0.1",
"futures-io", "futures-io",
@ -592,7 +592,7 @@ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"log", "log",
"polling 3.3.0", "polling 3.3.0",
"rustix 0.38.24", "rustix 0.38.25",
"slab", "slab",
"thiserror", "thiserror",
] ]
@ -604,7 +604,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02"
dependencies = [ dependencies = [
"calloop", "calloop",
"rustix 0.38.24", "rustix 0.38.25",
"wayland-backend 0.3.2", "wayland-backend 0.3.2",
"wayland-client 0.31.1", "wayland-client 0.31.1",
] ]
@ -959,6 +959,7 @@ dependencies = [
"nix 0.26.4", "nix 0.26.4",
"once_cell", "once_cell",
"rust-embed 6.8.1", "rust-embed 6.8.1",
"tracing",
] ]
[[package]] [[package]]
@ -993,7 +994,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config" name = "cosmic-config"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -1007,7 +1008,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config-derive" name = "cosmic-config-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -1107,7 +1108,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-theme" name = "cosmic-theme"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"almost", "almost",
"cosmic-config", "cosmic-config",
@ -1662,9 +1663,9 @@ dependencies = [
[[package]] [[package]]
name = "etagere" name = "etagere"
version = "0.2.8" version = "0.2.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcf22f748754352918e082e0039335ee92454a5d62bcaf69b5e8daf5907d9644" checksum = "306960881d6c46bd0dd6b7f07442a441418c08d0d3e63d8d080b0f64c6343e4e"
dependencies = [ dependencies = [
"euclid", "euclid",
"svg_fmt", "svg_fmt",
@ -2060,7 +2061,11 @@ version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb" checksum = "d3831c2651acb5177cbd83943f3d9c8912c5ad03c76afcc0e9511ba568ec5ebb"
dependencies = [ dependencies = [
"fastrand 2.0.1",
"futures-core", "futures-core",
"futures-io",
"memchr",
"parking",
"pin-project-lite", "pin-project-lite",
] ]
@ -2560,7 +2565,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"iced_accessibility", "iced_accessibility",
"iced_core", "iced_core",
@ -2575,7 +2580,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_accessibility" name = "iced_accessibility"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"accesskit_unix", "accesskit_unix",
@ -2584,7 +2589,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"iced_accessibility", "iced_accessibility",
@ -2600,7 +2605,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.7.0" version = "0.7.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -2613,7 +2618,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"bytemuck", "bytemuck",
@ -2631,7 +2636,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -2644,7 +2649,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.1.1" version = "0.1.1"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"iced_accessibility", "iced_accessibility",
"iced_core", "iced_core",
@ -2656,7 +2661,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_sctk" name = "iced_sctk"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"enum-repr", "enum-repr",
"float-cmp", "float-cmp",
@ -2680,7 +2685,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -2690,7 +2695,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -2708,7 +2713,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.11.1" version = "0.11.1"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"bytemuck", "bytemuck",
@ -2730,7 +2735,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.1.3" version = "0.1.3"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"iced_renderer", "iced_renderer",
"iced_runtime", "iced_runtime",
@ -2886,7 +2891,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [ dependencies = [
"hermit-abi 0.3.3", "hermit-abi 0.3.3",
"rustix 0.38.24", "rustix 0.38.25",
"windows-sys", "windows-sys",
] ]
@ -3002,10 +3007,11 @@ checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#448c777812c707717e2c6e4467a6e108aaf57f37" source = "git+https://github.com/pop-os/libcosmic#57f4abb8a000c0e554c77807100025301599cf3f"
dependencies = [ dependencies = [
"apply", "apply",
"ashpd", "ashpd",
"cosmic-client-toolkit",
"cosmic-config", "cosmic-config",
"cosmic-panel-config", "cosmic-panel-config",
"cosmic-theme", "cosmic-theme",
@ -3023,16 +3029,17 @@ dependencies = [
"iced_tiny_skia", "iced_tiny_skia",
"iced_widget", "iced_widget",
"lazy_static", "lazy_static",
"nix 0.26.4",
"palette", "palette",
"ron", "ron",
"slotmap", "slotmap",
"smithay-client-toolkit 0.18.0",
"taffy", "taffy",
"thiserror", "thiserror",
"tokio", "tokio",
"tracing", "tracing",
"unicode-segmentation", "unicode-segmentation",
"url", "url",
"zbus",
] ]
[[package]] [[package]]
@ -3203,9 +3210,9 @@ dependencies = [
[[package]] [[package]]
name = "lyon_algorithms" name = "lyon_algorithms"
version = "1.0.3" version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00a0349cd8f0270781bb93a824b63df6178e3b4a27794e7be3ce3763f5a44d6e" checksum = "a3bca95f9a4955b3e4a821fbbcd5edfbd9be2a9a50bb5758173e5358bfb4c623"
dependencies = [ dependencies = [
"lyon_path", "lyon_path",
"num-traits", "num-traits",
@ -3918,7 +3925,7 @@ dependencies = [
"cfg-if", "cfg-if",
"concurrent-queue", "concurrent-queue",
"pin-project-lite", "pin-project-lite",
"rustix 0.38.24", "rustix 0.38.25",
"tracing", "tracing",
"windows-sys", "windows-sys",
] ]
@ -4017,7 +4024,7 @@ dependencies = [
"hex", "hex",
"lazy_static", "lazy_static",
"procfs-core", "procfs-core",
"rustix 0.38.24", "rustix 0.38.25",
] ]
[[package]] [[package]]
@ -4378,9 +4385,9 @@ dependencies = [
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.38.24" version = "0.38.25"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ad981d6c340a49cdc40a1028d9c6084ec7e9fa33fcb839cab656a267071e234" checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"errno", "errno",
@ -4482,18 +4489,18 @@ dependencies = [
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.192" version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.192" version = "1.0.193"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -4654,7 +4661,7 @@ dependencies = [
"log", "log",
"memmap2 0.9.0", "memmap2 0.9.0",
"pkg-config", "pkg-config",
"rustix 0.38.24", "rustix 0.38.25",
"thiserror", "thiserror",
"wayland-backend 0.3.2", "wayland-backend 0.3.2",
"wayland-client 0.31.1", "wayland-client 0.31.1",
@ -4716,7 +4723,7 @@ dependencies = [
"objc", "objc",
"raw-window-handle", "raw-window-handle",
"redox_syscall 0.4.1", "redox_syscall 0.4.1",
"rustix 0.38.24", "rustix 0.38.25",
"tiny-xlib", "tiny-xlib",
"wasm-bindgen", "wasm-bindgen",
"wayland-backend 0.3.2", "wayland-backend 0.3.2",
@ -4874,7 +4881,7 @@ dependencies = [
[[package]] [[package]]
name = "taffy" name = "taffy"
version = "0.3.11" version = "0.3.11"
source = "git+https://github.com/DioxusLabs/taffy#1876f72bee5e376023eaa518aa7b8a34c769bd1b" source = "git+https://github.com/DioxusLabs/taffy#70b35712a2e79b6fdfef4cff4392ca94287cd0b1"
dependencies = [ dependencies = [
"arrayvec", "arrayvec",
"grid", "grid",
@ -4903,7 +4910,7 @@ dependencies = [
"cfg-if", "cfg-if",
"fastrand 2.0.1", "fastrand 2.0.1",
"redox_syscall 0.4.1", "redox_syscall 0.4.1",
"rustix 0.38.24", "rustix 0.38.25",
"windows-sys", "windows-sys",
] ]
@ -5025,9 +5032,9 @@ dependencies = [
[[package]] [[package]]
name = "tinystr" name = "tinystr"
version = "0.7.4" version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5d0e245e80bdc9b4e5356fc45a72184abbc3861992603f515270e9340f5a219" checksum = "83c02bf3c538ab32ba913408224323915f4ef9a6d61c0e85d493f355921c0ece"
dependencies = [ dependencies = [
"displaydoc", "displaydoc",
] ]
@ -5428,9 +5435,9 @@ dependencies = [
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.5.0" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
dependencies = [ dependencies = [
"getrandom", "getrandom",
] ]

View file

@ -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 = [ libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = [
"applet", "applet",
"applet-token",
"tokio", "tokio",
"wayland", "wayland",
"process",
] } ] }
zbus = { version = "3.14", default-features = false, features = ["tokio"] } zbus = { version = "3.14", default-features = false, features = ["tokio"] }
tracing = "0.1"
[profile.release] [profile.release]
lto = "thin" lto = "thin"

View file

@ -10,7 +10,9 @@ libcosmic.workspace = true
nix = "0.26.2" nix = "0.26.2"
chrono = { version = "0.4.23", features = ["clock"] } chrono = { version = "0.4.23", features = ["clock"] }
once_cell = "1" once_cell = "1"
tracing.workspace = true
# Application i18n # Application i18n
i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] } i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6.4" i18n-embed-fl = "0.6.4"
rust-embed = "6.3.0" rust-embed = "6.3.0"

View file

@ -9,3 +9,5 @@ Keywords=Cosmic;Iced;
Icon=com.system76.CosmicAppletTime Icon=com.system76.CosmicAppletTime
NoDisplay=true NoDisplay=true
X-CosmicApplet=true X-CosmicApplet=true
X-HostWaylandDisplay=true

View file

@ -1,4 +1,5 @@
use cosmic::applet::{menu_button, padded_control}; 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::wayland::popup::{destroy_popup, get_popup};
use cosmic::iced::{ use cosmic::iced::{
time, time,
@ -19,6 +20,9 @@ use std::time::Duration;
use crate::fl; use crate::fl;
use crate::time::get_calender_first; use crate::time::get_calender_first;
use cosmic::applet::token::subscription::{
activation_token_subscription, TokenRequest, TokenUpdate,
};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(dead_code)] #[allow(dead_code)]
@ -35,6 +39,7 @@ pub struct Window {
now: DateTime<Local>, now: DateTime<Local>,
rectangle_tracker: Option<RectangleTracker<u32>>, rectangle_tracker: Option<RectangleTracker<u32>>,
rectangle: Rectangle, rectangle: Rectangle,
token_tx: Option<calloop::channel::Sender<TokenRequest>>,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
@ -47,6 +52,7 @@ pub enum Message {
PreviousMonth, PreviousMonth,
NextMonth, NextMonth,
OpenDateTimeSettings, OpenDateTimeSettings,
Token(TokenUpdate),
} }
impl cosmic::Application for Window { impl cosmic::Application for Window {
@ -68,6 +74,7 @@ impl cosmic::Application for Window {
now: Local::now(), now: Local::now(),
rectangle_tracker: None, rectangle_tracker: None,
rectangle: Rectangle::default(), rectangle: Rectangle::default(),
token_tx: None,
}, },
Command::none(), Command::none(),
) )
@ -106,6 +113,7 @@ impl cosmic::Application for Window {
wait.try_into().unwrap_or(FALLBACK_DELAY), wait.try_into().unwrap_or(FALLBACK_DELAY),
)) ))
.map(|_| Message::Tick), .map(|_| Message::Tick),
activation_token_subscription(0).map(Message::Token),
]) ])
} }
@ -178,7 +186,35 @@ impl cosmic::Application for Window {
Command::none() Command::none()
} }
Message::OpenDateTimeSettings => { 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() Command::none()
} }
} }