Compare commits
2 commits
b50f75d868
...
f49bf7b949
Author | SHA1 | Date | |
---|---|---|---|
Alex Janka | f49bf7b949 | ||
Alex Janka | 77095d6653 |
149
Cargo.lock
generated
149
Cargo.lock
generated
|
@ -38,6 +38,15 @@ version = "1.0.86"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "approx"
|
||||||
|
version = "0.5.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
||||||
|
dependencies = [
|
||||||
|
"num-traits",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arc-swap"
|
name = "arc-swap"
|
||||||
version = "1.7.1"
|
version = "1.7.1"
|
||||||
|
@ -123,6 +132,12 @@ version = "3.16.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "by_address"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "64fa3c856b712db6612c019f14756e64e4bcea13337a6b33b696333a9eaa2d06"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
@ -137,9 +152,9 @@ checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.15"
|
version = "1.1.16"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6"
|
checksum = "e9d013ecb737093c0e86b151a7b837993cf9ec6c502946cfb44bedc392421e0b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"shlex",
|
"shlex",
|
||||||
]
|
]
|
||||||
|
@ -267,6 +282,12 @@ dependencies = [
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fast-srgb8"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd2e7510819d6fbf51a5545c8f922716ecfb14df168a3242f7d33e0239efe6a1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fastrand"
|
name = "fastrand"
|
||||||
version = "2.1.1"
|
version = "2.1.1"
|
||||||
|
@ -275,9 +296,9 @@ checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "filetime"
|
name = "filetime"
|
||||||
version = "0.2.24"
|
version = "0.2.25"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bf401df4a4e3872c4fe8151134cf483738e74b67fc934d6532c882b3d24a4550"
|
checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
|
@ -333,7 +354,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -422,9 +443,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.4.0"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c"
|
checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
|
@ -485,12 +506,6 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lab"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bf36173d4167ed999940f804952e6b08197cae5ad5d572eb4db150ce8ad5d58f"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.158"
|
version = "0.2.158"
|
||||||
|
@ -647,9 +662,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "object"
|
name = "object"
|
||||||
version = "0.36.3"
|
version = "0.36.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9"
|
checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
@ -675,6 +690,30 @@ dependencies = [
|
||||||
"num-traits",
|
"num-traits",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "palette"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4cbf71184cc5ecc2e4e1baccdb21026c20e5fc3dcf63028a086131b3ab00b6e6"
|
||||||
|
dependencies = [
|
||||||
|
"approx",
|
||||||
|
"fast-srgb8",
|
||||||
|
"palette_derive",
|
||||||
|
"phf",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "palette_derive"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f5030daf005bface118c096f510ffb781fc28f9ab6a32ab224d8631be6851d30"
|
||||||
|
dependencies = [
|
||||||
|
"by_address",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.77",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking"
|
name = "parking"
|
||||||
version = "2.2.0"
|
version = "2.2.0"
|
||||||
|
@ -704,6 +743,48 @@ dependencies = [
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
|
||||||
|
dependencies = [
|
||||||
|
"phf_macros",
|
||||||
|
"phf_shared",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_generator"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
|
||||||
|
dependencies = [
|
||||||
|
"phf_shared",
|
||||||
|
"rand",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_macros"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
|
||||||
|
dependencies = [
|
||||||
|
"phf_generator",
|
||||||
|
"phf_shared",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.77",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "phf_shared"
|
||||||
|
version = "0.11.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
|
||||||
|
dependencies = [
|
||||||
|
"siphasher",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.14"
|
version = "0.2.14"
|
||||||
|
@ -816,9 +897,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.38.34"
|
version = "0.38.35"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"errno",
|
"errno",
|
||||||
|
@ -875,14 +956,14 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.127"
|
version = "1.0.128"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad"
|
checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
|
@ -927,6 +1008,12 @@ dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "siphasher"
|
||||||
|
version = "0.3.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.9"
|
version = "0.4.9"
|
||||||
|
@ -954,15 +1041,15 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sway-flash-indicator"
|
name = "sway-flash-indicator"
|
||||||
version = "0.4.3"
|
version = "0.5.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"directories",
|
"directories",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"lab",
|
|
||||||
"log",
|
"log",
|
||||||
"log4rs",
|
"log4rs",
|
||||||
"notify",
|
"notify",
|
||||||
"notify-debouncer-mini",
|
"notify-debouncer-mini",
|
||||||
|
"palette",
|
||||||
"serde",
|
"serde",
|
||||||
"swayipc-async",
|
"swayipc-async",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
@ -1008,9 +1095,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.76"
|
version = "2.0.77"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525"
|
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -1034,7 +1121,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1049,9 +1136,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.39.3"
|
version = "1.40.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5"
|
checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -1073,7 +1160,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1194,7 +1281,7 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1216,7 +1303,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
@ -1442,5 +1529,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.76",
|
"syn 2.0.77",
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sway-flash-indicator"
|
name = "sway-flash-indicator"
|
||||||
version = "0.4.3"
|
version = "0.5.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
log4rs = "1.3.0"
|
log4rs = "1.3.0"
|
||||||
swayipc-async = "2.0.3"
|
swayipc-async = "2.0.3"
|
||||||
tokio = { version = "1.39.3", features = ["full"] }
|
tokio = { version = "1.40.0", features = ["full"] }
|
||||||
futures-util = "0.3.30"
|
futures-util = "0.3.30"
|
||||||
lab = "0.11.0"
|
|
||||||
directories = "5.0.1"
|
directories = "5.0.1"
|
||||||
toml = "0.8.19"
|
toml = "0.8.19"
|
||||||
serde = { version = "1.0.209", features = ["derive"] }
|
serde = { version = "1.0.209", features = ["derive"] }
|
||||||
thiserror = "1.0.63"
|
thiserror = "1.0.63"
|
||||||
notify-debouncer-mini = "0.4.1"
|
notify-debouncer-mini = "0.4.1"
|
||||||
notify = "6.1.1"
|
notify = "6.1.1"
|
||||||
|
palette = "0.7.6"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Maintainer: Alex Janka <alex@alexjanka.com>
|
# Maintainer: Alex Janka <alex@alexjanka.com>
|
||||||
|
|
||||||
pkgname=sway-flash-indicator
|
pkgname=sway-flash-indicator
|
||||||
pkgver=0.4.3
|
pkgver=0.5.0
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="flashes sway indicator border rather than always showing it"
|
pkgdesc="flashes sway indicator border rather than always showing it"
|
||||||
arch=('x86_64' 'aarch64')
|
arch=('x86_64' 'aarch64')
|
||||||
|
|
|
@ -1,11 +1,23 @@
|
||||||
use lab::Lab;
|
use palette::FromColor;
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
pub fn parse_hex(hex: &str) -> Res<Lab> {
|
pub type Format = palette::Oklab;
|
||||||
|
pub type RgbFormat = palette::Srgb<u8>;
|
||||||
|
|
||||||
|
pub fn parse_hex(hex: &str) -> Res<Format> {
|
||||||
let hex = hex.strip_prefix('#').unwrap_or(hex);
|
let hex = hex.strip_prefix('#').unwrap_or(hex);
|
||||||
let r = u8::from_str_radix(&hex[..2], 16).map_err(|_| Error::HexParse)?;
|
let r = u8::from_str_radix(&hex[..2], 16).map_err(|_| Error::HexParse)?;
|
||||||
let g = u8::from_str_radix(&hex[2..4], 16).map_err(|_| Error::HexParse)?;
|
let g = u8::from_str_radix(&hex[2..4], 16).map_err(|_| Error::HexParse)?;
|
||||||
let b = u8::from_str_radix(&hex[4..], 16).map_err(|_| Error::HexParse)?;
|
let b = u8::from_str_radix(&hex[4..], 16).map_err(|_| Error::HexParse)?;
|
||||||
Ok(Lab::from_rgb(&[r, g, b]))
|
let rgb_u8 = palette::rgb::Srgb::new(r, g, b);
|
||||||
|
let rgb_f32 = palette::rgb::Srgb::<f32>::from(rgb_u8);
|
||||||
|
let oklab = palette::Oklab::from_color(rgb_f32);
|
||||||
|
|
||||||
|
Ok(oklab)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn oklab_to_hex(oklab: &Format) -> String {
|
||||||
|
let (r, g, b) = RgbFormat::from(palette::Srgb::from_color(*oklab)).into_components();
|
||||||
|
format!("#{r:02x}{g:02x}{b:02x}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use lab::Lab;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
@ -10,7 +9,7 @@ pub struct Config {
|
||||||
pub frames_anim: u32,
|
pub frames_anim: u32,
|
||||||
pub refresh_rate: u64,
|
pub refresh_rate: u64,
|
||||||
#[serde(serialize_with = "lab_ser", deserialize_with = "lab_de")]
|
#[serde(serialize_with = "lab_ser", deserialize_with = "lab_de")]
|
||||||
pub flash_colour: Lab,
|
pub flash_colour: colour::Format,
|
||||||
pub autosplit_enabled: bool,
|
pub autosplit_enabled: bool,
|
||||||
pub autosplit_ratio: f64,
|
pub autosplit_ratio: f64,
|
||||||
pub output_blocklist: Vec<String>,
|
pub output_blocklist: Vec<String>,
|
||||||
|
@ -128,11 +127,7 @@ impl Default for Config {
|
||||||
frames_delay: 10,
|
frames_delay: 10,
|
||||||
frames_anim: 20,
|
frames_anim: 20,
|
||||||
refresh_rate: 60,
|
refresh_rate: 60,
|
||||||
flash_colour: Lab {
|
flash_colour: colour::parse_hex("#ff0000").unwrap(),
|
||||||
l: 53.2,
|
|
||||||
a: 80.1,
|
|
||||||
b: 67.2,
|
|
||||||
},
|
|
||||||
autosplit_enabled: true,
|
autosplit_enabled: true,
|
||||||
autosplit_ratio: 1.0,
|
autosplit_ratio: 1.0,
|
||||||
output_blocklist: Vec::new(),
|
output_blocklist: Vec::new(),
|
||||||
|
@ -141,14 +136,16 @@ impl Default for Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lab_ser<S: serde::Serializer>(colour: &Lab, serializer: S) -> Result<S::Ok, S::Error> {
|
fn lab_ser<S: serde::Serializer>(
|
||||||
let [r, g, b] = colour.to_rgb();
|
colour: &colour::Format,
|
||||||
format!("#{r:02x}{g:02x}{b:02x}").serialize(serializer)
|
serializer: S,
|
||||||
|
) -> Result<S::Ok, S::Error> {
|
||||||
|
colour::oklab_to_hex(colour).serialize(serializer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lab_de<'a, D: serde::Deserializer<'a>>(deserializer: D) -> Result<Lab, D::Error> {
|
fn lab_de<'a, D: serde::Deserializer<'a>>(deserializer: D) -> Result<colour::Format, D::Error> {
|
||||||
use serde::de::Error;
|
use serde::de::Error;
|
||||||
|
|
||||||
let hex = String::deserialize(deserializer)?;
|
let hex = String::deserialize(deserializer)?;
|
||||||
crate::colour::parse_hex(&hex).map_err(|_| D::Error::custom("couldn't parse hex"))
|
colour::parse_hex(&hex).map_err(|_| D::Error::custom("couldn't parse hex"))
|
||||||
}
|
}
|
||||||
|
|
13
src/flash.rs
13
src/flash.rs
|
@ -6,7 +6,7 @@ pub async fn interpolate_task() -> Res<()> {
|
||||||
let to = crate::DEFAULT_BORDER.get().ok_or(Error::NoMatchingConfig)?;
|
let to = crate::DEFAULT_BORDER.get().ok_or(Error::NoMatchingConfig)?;
|
||||||
let config = CONFIG.get().await;
|
let config = CONFIG.get().await;
|
||||||
let per_frame = 1.0 / config.frames_anim as f32;
|
let per_frame = 1.0 / config.frames_anim as f32;
|
||||||
let (d_l, d_a, d_b) = (
|
let (d_l, d_chroma, d_hue) = (
|
||||||
(to.l - config.flash_colour.l) * per_frame,
|
(to.l - config.flash_colour.l) * per_frame,
|
||||||
(to.a - config.flash_colour.a) * per_frame,
|
(to.a - config.flash_colour.a) * per_frame,
|
||||||
(to.b - config.flash_colour.b) * per_frame,
|
(to.b - config.flash_colour.b) * per_frame,
|
||||||
|
@ -20,8 +20,8 @@ pub async fn interpolate_task() -> Res<()> {
|
||||||
tokio::time::sleep(dur_per_frame * config.frames_delay).await;
|
tokio::time::sleep(dur_per_frame * config.frames_delay).await;
|
||||||
for _ in 0..config.frames_anim {
|
for _ in 0..config.frames_anim {
|
||||||
c.l += d_l;
|
c.l += d_l;
|
||||||
c.a += d_a;
|
c.a += d_chroma;
|
||||||
c.b += d_b;
|
c.b += d_hue;
|
||||||
|
|
||||||
connection.run_command(set_command(&c)?).await?;
|
connection.run_command(set_command(&c)?).await?;
|
||||||
|
|
||||||
|
@ -37,10 +37,11 @@ pub async fn interpolate_task() -> Res<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_command(colour: &lab::Lab) -> Res<String> {
|
fn set_command(colour: &colour::Format) -> Res<String> {
|
||||||
let [r, g, b] = colour.to_rgb();
|
let hex = colour::oklab_to_hex(colour);
|
||||||
|
|
||||||
Ok(format!(
|
Ok(format!(
|
||||||
"{} #{r:02x}{g:02x}{b:02x}",
|
"{} {hex}",
|
||||||
crate::DEFAULT_COLOURS_NO_INDICATOR
|
crate::DEFAULT_COLOURS_NO_INDICATOR
|
||||||
.get()
|
.get()
|
||||||
.ok_or(Error::NoMatchingConfig)?
|
.ok_or(Error::NoMatchingConfig)?
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use lab::Lab;
|
|
||||||
|
|
||||||
mod colour;
|
mod colour;
|
||||||
mod config;
|
mod config;
|
||||||
|
@ -8,6 +7,7 @@ mod flash;
|
||||||
mod logger;
|
mod logger;
|
||||||
|
|
||||||
pub mod prelude {
|
pub mod prelude {
|
||||||
|
pub(crate) use crate::colour;
|
||||||
pub use crate::error::*;
|
pub use crate::error::*;
|
||||||
pub use crate::CONFIG;
|
pub use crate::CONFIG;
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ pub static CONFIG: config::ConfigHandle = config::ConfigHandle::new();
|
||||||
static DEFAULT_COLOURS: tokio::sync::OnceCell<String> = tokio::sync::OnceCell::const_new();
|
static DEFAULT_COLOURS: tokio::sync::OnceCell<String> = tokio::sync::OnceCell::const_new();
|
||||||
static DEFAULT_COLOURS_NO_INDICATOR: tokio::sync::OnceCell<String> =
|
static DEFAULT_COLOURS_NO_INDICATOR: tokio::sync::OnceCell<String> =
|
||||||
tokio::sync::OnceCell::const_new();
|
tokio::sync::OnceCell::const_new();
|
||||||
static DEFAULT_BORDER: tokio::sync::OnceCell<Lab> = tokio::sync::OnceCell::const_new();
|
static DEFAULT_BORDER: tokio::sync::OnceCell<colour::Format> = tokio::sync::OnceCell::const_new();
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Res<()> {
|
async fn main() -> Res<()> {
|
||||||
|
|
Loading…
Reference in a new issue