feat(wallpaper): get last active image from cosmic-bg when toggling slideshow
This commit is contained in:
parent
cff91ea1a4
commit
d943b5bd70
3 changed files with 93 additions and 56 deletions
83
Cargo.lock
generated
83
Cargo.lock
generated
|
|
@ -120,9 +120,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle"
|
name = "anstyle"
|
||||||
version = "1.0.4"
|
version = "1.0.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
|
checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstyle-parse"
|
name = "anstyle-parse"
|
||||||
|
|
@ -994,7 +994,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-bg-config"
|
name = "cosmic-bg-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-bg#6a6fe4e387e46c2e159df56a9768220a6269ccf4"
|
source = "git+https://github.com/pop-os/cosmic-bg#5c8a91f8904a39af50369dce2557d9ccb923b4b3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"colorgrad",
|
"colorgrad",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1028,7 +1028,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#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomicwrites",
|
"atomicwrites",
|
||||||
"calloop",
|
"calloop",
|
||||||
|
|
@ -1046,7 +1046,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#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.109",
|
"syn 1.0.109",
|
||||||
|
|
@ -1055,7 +1055,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-panel-config"
|
name = "cosmic-panel-config"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-panel#f7c57a093ff88c6b403aad136ec45f15f73edb5e"
|
source = "git+https://github.com/pop-os/cosmic-panel#9fe7f3ad19f69040ed88441e708f88f80cfc07ce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1192,7 +1192,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmic-text"
|
name = "cosmic-text"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
source = "git+https://github.com/pop-os/cosmic-text.git#e0ae465f918cd1cffca3a8239547dcf8166d3f77"
|
source = "git+https://github.com/pop-os/cosmic-text.git#0cea55630c97a47207f84e4cc3530404e17b6bfe"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.4.2",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
|
@ -1214,7 +1214,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#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"almost",
|
"almost",
|
||||||
"cosmic-config",
|
"cosmic-config",
|
||||||
|
|
@ -1338,9 +1338,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling"
|
name = "darling"
|
||||||
version = "0.20.3"
|
version = "0.20.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0209d94da627ab5605dcccf08bb18afa5009cfbef48d8a8b7d7bdbc79be25c5e"
|
checksum = "fc5d6b04b3fd0ba9926f945895de7d806260a2d7431ba82e7edaecb043c4c6b8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"darling_macro",
|
"darling_macro",
|
||||||
|
|
@ -1348,9 +1348,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling_core"
|
name = "darling_core"
|
||||||
version = "0.20.3"
|
version = "0.20.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "177e3443818124b357d8e76f53be906d60937f0d3a90773a664fa63fa253e621"
|
checksum = "04e48a959bcd5c761246f5d090ebc2fbf7b9cd527a492b07a67510c108f1e7e3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fnv",
|
"fnv",
|
||||||
"ident_case",
|
"ident_case",
|
||||||
|
|
@ -1362,9 +1362,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "darling_macro"
|
name = "darling_macro"
|
||||||
version = "0.20.3"
|
version = "0.20.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "836a9bbc7ad63342d6d6e7b815ccab164bc77a2d95d84bc3117a8c0d5c98e2d5"
|
checksum = "1d1545d67a2149e1d93b7e5c7752dce5a7426eb5d1357ddcfd89336b94444f77"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"darling_core",
|
"darling_core",
|
||||||
"quote",
|
"quote",
|
||||||
|
|
@ -1828,6 +1828,12 @@ version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "font-types"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0bd7f3ea17572640b606b35df42cfb6ecdf003704b062580e59918692190b73d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fontconfig-parser"
|
name = "fontconfig-parser"
|
||||||
version = "0.5.6"
|
version = "0.5.6"
|
||||||
|
|
@ -2479,7 +2485,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced"
|
name = "iced"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2494,7 +2500,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#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"accesskit",
|
"accesskit",
|
||||||
"accesskit_unix",
|
"accesskit_unix",
|
||||||
|
|
@ -2503,7 +2509,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_core"
|
name = "iced_core"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
|
|
@ -2521,7 +2527,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_futures"
|
name = "iced_futures"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2534,7 +2540,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_graphics"
|
name = "iced_graphics"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2557,7 +2563,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_renderer"
|
name = "iced_renderer"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_graphics",
|
"iced_graphics",
|
||||||
"iced_tiny_skia",
|
"iced_tiny_skia",
|
||||||
|
|
@ -2570,7 +2576,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_runtime"
|
name = "iced_runtime"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_accessibility",
|
"iced_accessibility",
|
||||||
"iced_core",
|
"iced_core",
|
||||||
|
|
@ -2582,7 +2588,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#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enum-repr",
|
"enum-repr",
|
||||||
"float-cmp",
|
"float-cmp",
|
||||||
|
|
@ -2606,7 +2612,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_style"
|
name = "iced_style"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_core",
|
"iced_core",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
@ -2616,7 +2622,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_tiny_skia"
|
name = "iced_tiny_skia"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"cosmic-text",
|
"cosmic-text",
|
||||||
|
|
@ -2634,7 +2640,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_wgpu"
|
name = "iced_wgpu"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 1.3.2",
|
"bitflags 1.3.2",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
|
|
@ -2654,7 +2660,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "iced_widget"
|
name = "iced_widget"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"iced_renderer",
|
"iced_renderer",
|
||||||
"iced_runtime",
|
"iced_runtime",
|
||||||
|
|
@ -3060,7 +3066,7 @@ checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libcosmic"
|
name = "libcosmic"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#1291a48d4d62f1da5ca178292a3ce0082204d8d4"
|
source = "git+https://github.com/pop-os/libcosmic#bf0508816b7e7098cfcc6eb16ee288207ef0cc31"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"apply",
|
"apply",
|
||||||
"ashpd",
|
"ashpd",
|
||||||
|
|
@ -4014,9 +4020,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "profiling"
|
name = "profiling"
|
||||||
version = "1.0.13"
|
version = "1.0.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d135ede8821cf6376eb7a64148901e1690b788c11ae94dc297ae917dbc91dc0e"
|
checksum = "0f0f7f43585c34e4fdd7497d746bc32e14458cf11c69341cc0587b1d825dde42"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ptr_meta"
|
name = "ptr_meta"
|
||||||
|
|
@ -4154,6 +4160,15 @@ version = "0.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f"
|
checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "read-fonts"
|
||||||
|
version = "0.15.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7555e052e772f964a1c99f1434f6a2c3a47a5f8e4292236921f121a7753cb2b5"
|
||||||
|
dependencies = [
|
||||||
|
"font-types",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
|
@ -4833,10 +4848,11 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swash"
|
name = "swash"
|
||||||
version = "0.1.8"
|
version = "0.1.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3b7c73c813353c347272919aa1af2885068b05e625e5532b43049e4f641ae77f"
|
checksum = "53dab2b2dc9257aead8a24ef0481b253f4c73479ce4d3b4266792dce6870d4f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"read-fonts",
|
||||||
"yazi",
|
"yazi",
|
||||||
"zeno",
|
"zeno",
|
||||||
]
|
]
|
||||||
|
|
@ -4877,14 +4893,13 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "synstructure"
|
name = "synstructure"
|
||||||
version = "0.13.0"
|
version = "0.13.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "285ba80e733fac80aa4270fbcdf83772a79b80aa35c97075320abfee4a915b06"
|
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.48",
|
"syn 2.0.48",
|
||||||
"unicode-xid",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -315,10 +315,19 @@ impl Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cache_display_image(&mut self) {
|
fn cache_display_image(&mut self) {
|
||||||
|
self.cached_display_handle = None;
|
||||||
|
|
||||||
let choice = match self.selection.active {
|
let choice = match self.selection.active {
|
||||||
Choice::Wallpaper(id) => self.selection.display_images.get(id),
|
Choice::Wallpaper(id) => self.selection.display_images.get(id),
|
||||||
|
|
||||||
Choice::Slideshow => self.selection.display_images.values().next(),
|
Choice::Slideshow => self
|
||||||
|
.config_output()
|
||||||
|
.and_then(|output| {
|
||||||
|
let path = wallpaper::current_image(output).ok()?;
|
||||||
|
let id = self.wallpaper_id_from_path(&path)?;
|
||||||
|
Some(&self.selection.display_images[id])
|
||||||
|
})
|
||||||
|
.or(self.selection.display_images.values().next()),
|
||||||
|
|
||||||
Choice::Color(_) => None,
|
Choice::Color(_) => None,
|
||||||
};
|
};
|
||||||
|
|
@ -327,8 +336,6 @@ impl Page {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
self.cached_display_handle = None;
|
|
||||||
|
|
||||||
let temp_image;
|
let temp_image;
|
||||||
|
|
||||||
let image = match self.selected_fit {
|
let image = match self.selected_fit {
|
||||||
|
|
@ -369,20 +376,19 @@ impl Page {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config_output(&self) -> Option<String> {
|
fn config_output(&self) -> Option<&str> {
|
||||||
if self.wallpaper_service_config.same_on_all {
|
if self.wallpaper_service_config.same_on_all {
|
||||||
Some(String::from("all"))
|
Some("all")
|
||||||
} else {
|
} else {
|
||||||
self.outputs
|
self.outputs
|
||||||
.active_data::<OutputName>()
|
.active_data::<OutputName>()
|
||||||
.cloned()
|
.map(|name| name.0.as_str())
|
||||||
.map(|name| name.0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies the current settings to cosmic-bg.
|
/// Applies the current settings to cosmic-bg.
|
||||||
pub fn config_apply(&mut self) {
|
pub fn config_apply(&mut self) {
|
||||||
let Some(output) = self.config_output() else {
|
let Some(output) = self.config_output().map(String::from) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -400,10 +406,9 @@ impl Page {
|
||||||
|
|
||||||
let entry = match self.selection.active {
|
let entry = match self.selection.active {
|
||||||
Choice::Slideshow => {
|
Choice::Slideshow => {
|
||||||
match self.config_wallpaper_entry(
|
match self
|
||||||
output.clone(),
|
.config_wallpaper_entry(output, self.config.current_folder().to_path_buf())
|
||||||
self.config.current_folder().to_path_buf(),
|
{
|
||||||
) {
|
|
||||||
Some(entry) => entry,
|
Some(entry) => entry,
|
||||||
None => return,
|
None => return,
|
||||||
}
|
}
|
||||||
|
|
@ -411,7 +416,7 @@ impl Page {
|
||||||
|
|
||||||
Choice::Wallpaper(key) => {
|
Choice::Wallpaper(key) => {
|
||||||
if let Some(path) = self.selection.paths.get(key) {
|
if let Some(path) = self.selection.paths.get(key) {
|
||||||
match self.config_wallpaper_entry(output.clone(), path.clone()) {
|
match self.config_wallpaper_entry(output, path.clone()) {
|
||||||
Some(entry) => entry,
|
Some(entry) => entry,
|
||||||
None => return,
|
None => return,
|
||||||
}
|
}
|
||||||
|
|
@ -420,9 +425,7 @@ impl Page {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Choice::Color(ref color) => {
|
Choice::Color(ref color) => Entry::new(output, wallpaper::Source::Color(color.clone())),
|
||||||
Entry::new(output.clone(), wallpaper::Source::Color(color.clone()))
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
wallpaper::set(&mut self.wallpaper_service_config, entry);
|
wallpaper::set(&mut self.wallpaper_service_config, entry);
|
||||||
|
|
@ -767,6 +770,20 @@ impl Page {
|
||||||
self.selection.active = Choice::Slideshow;
|
self.selection.active = Choice::Slideshow;
|
||||||
self.cache_display_image();
|
self.cache_display_image();
|
||||||
} else {
|
} else {
|
||||||
|
if let Some(output) = self.config_output() {
|
||||||
|
if let Ok(path) = wallpaper::current_image(output) {
|
||||||
|
if let Some(entity) = self.wallpaper_id_from_path(&path) {
|
||||||
|
if let Some(entry) =
|
||||||
|
self.config_wallpaper_entry(output.to_owned(), path)
|
||||||
|
{
|
||||||
|
self.select_wallpaper(&entry, entity, false);
|
||||||
|
self.config_apply();
|
||||||
|
return Command::none();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.select_first_wallpaper();
|
self.select_first_wallpaper();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -908,8 +925,9 @@ impl Page {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(output) = self.config_output() {
|
if let Some(output) = self.config_output() {
|
||||||
if let Some(entry) = self.config_wallpaper_entry(output, path.clone()) {
|
let is_slideshow = path.is_dir();
|
||||||
self.select_wallpaper(&entry, entity, path.is_dir());
|
if let Some(entry) = self.config_wallpaper_entry(output.to_owned(), path.clone()) {
|
||||||
|
self.select_wallpaper(&entry, entity, is_slideshow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,10 @@ pub const DEFAULT_COLORS: &[Color] = &[
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
pub fn current_image(output: &str) -> Result<PathBuf, cosmic_config::Error> {
|
||||||
|
cosmic_bg_config::context()?.current_image(output)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn config() -> (Config, HashMap<String, (String, (u32, u32))>) {
|
pub async fn config() -> (Config, HashMap<String, (String, (u32, u32))>) {
|
||||||
let mut displays = HashMap::new();
|
let mut displays = HashMap::new();
|
||||||
|
|
||||||
|
|
@ -52,9 +56,9 @@ pub async fn config() -> (Config, HashMap<String, (String, (u32, u32))>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let helper = Config::helper().expect("failed to get helper for cosmic bg config");
|
let context = cosmic_bg_config::context().expect("failed to get helper for cosmic bg config");
|
||||||
|
|
||||||
let config = match Config::load(&helper) {
|
let config = match Config::load(&context) {
|
||||||
Ok(conf) => conf,
|
Ok(conf) => conf,
|
||||||
Err(why) => {
|
Err(why) => {
|
||||||
tracing::warn!(?why, "Config file error, falling back to defaults");
|
tracing::warn!(?why, "Config file error, falling back to defaults");
|
||||||
|
|
@ -66,8 +70,8 @@ pub async fn config() -> (Config, HashMap<String, (String, (u32, u32))>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set(config: &mut Config, entry: Entry) {
|
pub fn set(config: &mut Config, entry: Entry) {
|
||||||
if let Ok(context) = Config::helper() {
|
if let Ok(context) = cosmic_bg_config::context() {
|
||||||
let _res = Config::set_same_on_all(&context, config.same_on_all);
|
let _res = context.set_same_on_all(config.same_on_all);
|
||||||
|
|
||||||
if let Err(why) = config.set_entry(&context, entry) {
|
if let Err(why) = config.set_entry(&context, entry) {
|
||||||
tracing::error!(?why, "failed to set background");
|
tracing::error!(?why, "failed to set background");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue