chore(release): v0.1.5 - Linux ksni tray, 1:1 sidebar collapse button, zero-overhead Linux RAM tuning

This commit is contained in:
marwy 2026-11-27 18:35:49 +03:00
parent f063382410
commit ee65d23b2a
9 changed files with 684 additions and 48 deletions

334
Cargo.lock generated
View file

@ -186,6 +186,15 @@ dependencies = [
"x11rb", "x11rb",
] ]
[[package]]
name = "arc-swap"
version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b5d51209f6de83d37a0b33d320acb8da88823e42a94c075140708f032a5"
dependencies = [
"rustversion",
]
[[package]] [[package]]
name = "arrayref" name = "arrayref"
version = "0.3.9" version = "0.3.9"
@ -224,6 +233,18 @@ dependencies = [
"raw-window-metal", "raw-window-metal",
] ]
[[package]]
name = "async-broadcast"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "435a87a52755b8f27fcf321ac4f04b2802e337c8c4872923137471ec39c37532"
dependencies = [
"event-listener",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]] [[package]]
name = "async-compression" name = "async-compression"
version = "0.4.52" version = "0.4.52"
@ -236,6 +257,28 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "async-recursion"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]]
name = "async-trait"
version = "0.1.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]] [[package]]
name = "atk" name = "atk"
version = "0.18.2" version = "0.18.2"
@ -849,6 +892,15 @@ dependencies = [
"crossbeam-utils", "crossbeam-utils",
] ]
[[package]]
name = "crossbeam-queue"
version = "0.3.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03e8bd762f7479489c70ed6c768ddca99d7296857de437a68dcb2a94365b3fae"
dependencies = [
"crossbeam-utils",
]
[[package]] [[package]]
name = "crossbeam-utils" name = "crossbeam-utils"
version = "0.8.23" version = "0.8.23"
@ -1085,6 +1137,33 @@ dependencies = [
"simdutf8", "simdutf8",
] ]
[[package]]
name = "endi"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66b7e2430c6dff6a955451e2cfc438f09cea1965a9d6f87f7e3b90decc014099"
[[package]]
name = "enumflags2"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef"
dependencies = [
"enumflags2_derive",
"serde",
]
[[package]]
name = "enumflags2_derive"
version = "0.7.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]] [[package]]
name = "env_filter" name = "env_filter"
version = "2.1.0" version = "2.1.0"
@ -1139,12 +1218,38 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "event-listener"
version = "5.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2"
dependencies = [
"parking",
"pin-project-lite",
]
[[package]]
name = "event-listener-strategy"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93"
dependencies = [
"event-listener",
"pin-project-lite",
]
[[package]] [[package]]
name = "extended" name = "extended"
version = "0.1.0" version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365" checksum = "af9673d8203fcb076b19dfd17e38b3d4ae9f44959416ea532ce72415a6020365"
[[package]]
name = "fastrand"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
[[package]] [[package]]
name = "fax" name = "fax"
version = "0.2.7" version = "0.2.7"
@ -1333,6 +1438,19 @@ version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
[[package]]
name = "futures-lite"
version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad"
dependencies = [
"fastrand",
"futures-core",
"futures-io",
"parking",
"pin-project-lite",
]
[[package]] [[package]]
name = "futures-macro" name = "futures-macro"
version = "0.3.34" version = "0.3.34"
@ -2350,6 +2468,21 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]]
name = "ksni"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d49a7ac89853917f01d75f6bac3e7c8e282ae621dd63fbbfc50fe331304fa580"
dependencies = [
"arc-swap",
"crossbeam-queue",
"futures-util",
"pastey",
"serde",
"tokio",
"zbus",
]
[[package]] [[package]]
name = "kuchikiki" name = "kuchikiki"
version = "0.8.2" version = "0.8.2"
@ -3195,6 +3328,16 @@ dependencies = [
"libredox", "libredox",
] ]
[[package]]
name = "ordered-stream"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50"
dependencies = [
"futures-core",
"pin-project-lite",
]
[[package]] [[package]]
name = "owned_ttf_parser" name = "owned_ttf_parser"
version = "0.25.1" version = "0.25.1"
@ -3229,6 +3372,12 @@ dependencies = [
"system-deps", "system-deps",
] ]
[[package]]
name = "parking"
version = "2.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba"
[[package]] [[package]]
name = "parking_lot" name = "parking_lot"
version = "0.12.5" version = "0.12.5"
@ -3252,6 +3401,12 @@ dependencies = [
"windows-link 0.2.1", "windows-link 0.2.1",
] ]
[[package]]
name = "pastey"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.2" version = "2.3.2"
@ -4211,6 +4366,17 @@ dependencies = [
"zmij", "zmij",
] ]
[[package]]
name = "serde_repr"
version = "0.1.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.10",
]
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.9" version = "0.6.9"
@ -4265,6 +4431,16 @@ 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 = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"
dependencies = [
"errno",
"libc",
]
[[package]] [[package]]
name = "simd-adler32" name = "simd-adler32"
version = "0.3.10" version = "0.3.10"
@ -4817,6 +4993,19 @@ version = "0.12.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
[[package]]
name = "tempfile"
version = "3.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom 0.4.3",
"once_cell",
"rustix 1.1.6",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "tendril" name = "tendril"
version = "0.4.3" version = "0.4.3"
@ -4979,8 +5168,10 @@ dependencies = [
"libc", "libc",
"mio", "mio",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry",
"socket2", "socket2",
"tokio-macros", "tokio-macros",
"tracing",
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
@ -5150,9 +5341,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
dependencies = [ dependencies = [
"pin-project-lite", "pin-project-lite",
"tracing-attributes",
"tracing-core", "tracing-core",
] ]
[[package]]
name = "tracing-attributes"
version = "0.1.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.119",
]
[[package]] [[package]]
name = "tracing-core" name = "tracing-core"
version = "0.1.36" version = "0.1.36"
@ -5204,6 +5407,17 @@ version = "1.20.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20"
[[package]]
name = "uds_windows"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e"
dependencies = [
"memoffset",
"tempfile",
"windows-sys 0.61.2",
]
[[package]] [[package]]
name = "unicode-bidi" name = "unicode-bidi"
version = "0.3.18" version = "0.3.18"
@ -5348,6 +5562,17 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6" checksum = "3a3b425286980a367278453f3b6d28cdcb134b574e5a35824a6ff5eebad50bb6"
[[package]]
name = "uuid"
version = "1.29.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64"
dependencies = [
"js-sys",
"serde_core",
"wasm-bindgen",
]
[[package]] [[package]]
name = "version-compare" name = "version-compare"
version = "0.2.1" version = "0.2.1"
@ -6325,7 +6550,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]] [[package]]
name = "yandex-music-rs" name = "yandex-music-rs"
version = "0.1.4" version = "0.1.5"
dependencies = [ dependencies = [
"aes", "aes",
"anyhow", "anyhow",
@ -6347,6 +6572,7 @@ dependencies = [
"hex", "hex",
"hmac", "hmac",
"image", "image",
"ksni",
"log", "log",
"lru", "lru",
"md-5", "md-5",
@ -6400,6 +6626,71 @@ dependencies = [
"synstructure", "synstructure",
] ]
[[package]]
name = "zbus"
version = "5.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5db4be7c075cb421e4b7ee645541604239bd243ba7c357511f4ff3a74b555907"
dependencies = [
"async-broadcast",
"async-recursion",
"async-trait",
"enumflags2",
"event-listener",
"futures-core",
"futures-lite",
"hex",
"libc",
"ordered-stream",
"rustix 1.1.6",
"serde",
"serde_repr",
"tokio",
"tracing",
"uds_windows",
"uuid",
"windows-sys 0.61.2",
"winnow 1.0.5",
"zbus_macros",
"zbus_names",
"zvariant",
]
[[package]]
name = "zbus_macros"
version = "5.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2990635d09ade6df1868f72f8cac69a876a90981e8bd3c40b1be413f8dc88f40"
dependencies = [
"proc-macro-crate 3.5.0",
"proc-macro2",
"quote",
"syn 3.0.10",
"zbus_names",
"zvariant",
"zvariant_utils",
]
[[package]]
name = "zbus_names"
version = "4.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812a12be4ead7a59e18ea8f047d08add0066b73bc62fc1467066a2472ae088dd"
dependencies = [
"serde",
"winnow 1.0.5",
"zvariant",
]
[[package]]
name = "zcheapstr"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da34e7164b75d803c3197b86e6cf61b874106fbd472c5082575a8bc5fbd0907"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "zeno" name = "zeno"
version = "0.3.3" version = "0.3.3"
@ -6527,3 +6818,44 @@ checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296"
dependencies = [ dependencies = [
"zune-core 0.5.3", "zune-core 0.5.3",
] ]
[[package]]
name = "zvariant"
version = "5.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80bf6d6cd6a4b601acb64cfb8284cdc643fcfa75ef26ae3c46ec8aa4e8a1fbb7"
dependencies = [
"endi",
"enumflags2",
"serde",
"winnow 1.0.5",
"zcheapstr",
"zvariant_derive",
"zvariant_utils",
]
[[package]]
name = "zvariant_derive"
version = "5.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef2672456ba1cb54b5eaec136e63135b3c7495fb938e53b28a62e633496d486d"
dependencies = [
"proc-macro-crate 3.5.0",
"proc-macro2",
"quote",
"syn 3.0.10",
"zvariant_utils",
]
[[package]]
name = "zvariant_utils"
version = "4.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad0294361a320b694a328460dc73add56c306150f5cb6bfafc44446120008a3"
dependencies = [
"proc-macro2",
"quote",
"serde",
"syn 3.0.10",
"winnow 1.0.5",
]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "yandex-music-rs" name = "yandex-music-rs"
version = "0.1.4" version = "0.1.5"
edition = "2021" edition = "2021"
description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust + ash Vulkan SDF + taffy + cosmic-text" description = "Native high-performance, ultra-low-RAM Yandex Music desktop client in Rust + ash Vulkan SDF + taffy + cosmic-text"
@ -81,6 +81,7 @@ windows-sys = { version = "0.59", features = [
] } ] }
[target.'cfg(target_os = "linux")'.dependencies] [target.'cfg(target_os = "linux")'.dependencies]
ksni = { version = "0.3", features = ["blocking"] }
wry = { version = "0.51", default-features = false, features = ["os-webview"], optional = true } wry = { version = "0.51", default-features = false, features = ["os-webview"], optional = true }
gtk = { version = "0.18", optional = true } gtk = { version = "0.18", optional = true }

View file

@ -10,12 +10,12 @@
Готовые сборки доступны на странице [Releases](https://git.tatar/marwy/yandex-music-rs/releases): Готовые сборки доступны на странице [Releases](https://git.tatar/marwy/yandex-music-rs/releases):
- **Windows (x64)**: скачайте `yandex-music-rs-v0.1.4-windows-x86_64.exe` и запустите (переносной файл, установка не требуется). - **Windows (x64)**: скачайте `yandex-music-rs-v0.1.5-windows-x86_64.exe` и запустите (переносной файл, установка не требуется).
- **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.4-1_amd64.deb` и установите: - **Linux (Debian / Ubuntu x64)**: скачайте `yandex-music-rs_0.1.5-1_amd64.deb` и установите:
```bash ```bash
sudo apt install ./yandex-music-rs_0.1.4-1_amd64.deb sudo apt install ./yandex-music-rs_0.1.5-1_amd64.deb
``` ```
- **Linux (generic x64)**: архив `yandex-music-rs-v0.1.4-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`). - **Linux (generic x64)**: архив `yandex-music-rs-v0.1.5-linux-x86_64.tar.gz` с готовыми бинарниками (`yandex-music-rs` + `yandex-music-auth`).
## Стек и возможности ## Стек и возможности

View file

@ -7,9 +7,16 @@ use std::sync::Arc;
use crate::engine::textures::TextureRegistry; use crate::engine::textures::TextureRegistry;
use crate::engine::types::{Color, TextureId}; use crate::engine::types::{Color, TextureId};
/// Hard minimum LRU cover cache capacity so even dense pages (Artist/Collection + sidebar + player) /// Hard minimum LRU cover cache capacity.
/// can never thrash or flicker visible avatars/covers. /// Leaner on Linux integrated-GPU (UMA) builds where GL textures live directly in system RAM!
#[cfg(all(target_os = "linux", not(test)))]
pub const MIN_COVER_CACHE_CAPACITY: usize = 64;
#[cfg(not(all(target_os = "linux", not(test))))]
pub const MIN_COVER_CACHE_CAPACITY: usize = 128; pub const MIN_COVER_CACHE_CAPACITY: usize = 128;
#[cfg(all(target_os = "linux", not(test)))]
const MAX_AUTO_GROW_CAPACITY: usize = 128;
#[cfg(not(all(target_os = "linux", not(test))))]
const MAX_AUTO_GROW_CAPACITY: usize = 1024; const MAX_AUTO_GROW_CAPACITY: usize = 1024;
pub struct CoverEntry { pub struct CoverEntry {

View file

@ -332,8 +332,25 @@ impl TextEngine {
db.set_sans_serif_family(&ys_text_family); db.set_sans_serif_family(&ys_text_family);
// Load system fallback fonts for rare symbols / emoji / CJK // On Linux, avoid indexing all 400+ system fonts (saves 20-40 MB RSS from Noto CJK/Emoji);
db.load_system_fonts(); // load only 1-2 lean symbol/fallback faces alongside our 4 embedded official Yandex fonts.
#[cfg(target_os = "linux")]
{
for path in [
"/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",
"/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf",
"/usr/share/fonts/truetype/noto/NotoSansSymbols2-Regular.ttf",
] {
if std::path::Path::new(path).is_file() {
let _ = db.load_font_file(path);
}
}
}
#[cfg(not(target_os = "linux"))]
{
// Load system fallback fonts for rare symbols / emoji / CJK
db.load_system_fonts();
}
let font_system = FontSystem::new_with_locale_and_db("ru-RU".to_string(), db); let font_system = FontSystem::new_with_locale_and_db("ru-RU".to_string(), db);

View file

@ -1058,7 +1058,25 @@ fn acquire_single_instance_lock() -> bool {
true true
} }
#[cfg(all(target_os = "linux", target_env = "gnu"))]
fn tune_linux_glibc_allocator() {
extern "C" {
fn mallopt(param: std::ffi::c_int, value: std::ffi::c_int) -> std::ffi::c_int;
}
const M_TRIM_THRESHOLD: std::ffi::c_int = -1;
const M_MMAP_THRESHOLD: std::ffi::c_int = -3;
const M_ARENA_MAX: std::ffi::c_int = -8;
unsafe {
let _ = mallopt(M_ARENA_MAX, 2);
let _ = mallopt(M_TRIM_THRESHOLD, 128 * 1024);
let _ = mallopt(M_MMAP_THRESHOLD, 128 * 1024);
}
}
fn main() { fn main() {
#[cfg(all(target_os = "linux", target_env = "gnu"))]
tune_linux_glibc_allocator();
// Isolated Vulkan HW probe subprocess (keeps libvulkan_lvp / libLLVM out of main Linux RSS) // Isolated Vulkan HW probe subprocess (keeps libvulkan_lvp / libLLVM out of main Linux RSS)
if std::env::args().any(|a| a == "--probe-vulkan") { if std::env::args().any(|a| a == "--probe-vulkan") {
std::process::exit(if VulkanContext::has_hardware_vulkan() { 0 } else { 1 }); std::process::exit(if VulkanContext::has_hardware_vulkan() { 0 } else { 1 });

View file

@ -451,22 +451,267 @@ mod imp {
mod imp { mod imp {
use super::NativeEvent; use super::NativeEvent;
use crate::api::models::Track; use crate::api::models::Track;
use crossbeam_channel::{unbounded, Receiver, Sender};
use ksni::blocking::{Handle, TrayMethods};
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
use std::process::{Command, Stdio}; use std::process::{Command, Stdio};
use std::sync::Arc;
use winit::window::Window; use winit::window::Window;
const OAUTH_TOKEN_PREFIX: &str = "YM_OAUTH_TOKEN:"; const OAUTH_TOKEN_PREFIX: &str = "YM_OAUTH_TOKEN:";
pub struct NativeDesktop; struct LinuxTray {
tx: Sender<NativeEvent>,
icons: Arc<Vec<ksni::Icon>>,
is_ru: bool,
window_visible: bool,
is_playing: bool,
track_summary: String,
}
impl ksni::Tray for LinuxTray {
fn id(&self) -> String {
"yandex-music-rs".into()
}
fn category(&self) -> ksni::Category {
ksni::Category::ApplicationStatus
}
fn title(&self) -> String {
if self.is_ru {
"Яндекс Музыка".into()
} else {
"Yandex Music".into()
}
}
fn icon_name(&self) -> String {
"yandex-music-rs".into()
}
fn icon_pixmap(&self) -> Vec<ksni::Icon> {
(*self.icons).clone()
}
fn tool_tip(&self) -> ksni::ToolTip {
ksni::ToolTip {
icon_name: "yandex-music-rs".into(),
icon_pixmap: Vec::new(),
title: self.title(),
description: self.track_summary.clone(),
}
}
fn activate(&mut self, _x: i32, _y: i32) {
let _ = self.tx.send(NativeEvent::ToggleWindow);
}
fn menu(&self) -> Vec<ksni::MenuItem<Self>> {
use ksni::menu::*;
let toggle_label = if self.window_visible {
if self.is_ru { "Скрыть" } else { "Hide" }
} else if self.is_ru {
"Показать"
} else {
"Show"
};
let play_label = if self.is_playing {
if self.is_ru { "Пауза" } else { "Pause" }
} else if self.is_ru {
"Играть"
} else {
"Play"
};
let ver_label = if self.is_ru {
format!("Яндекс Музыка {}", env!("CARGO_PKG_VERSION"))
} else {
format!("Yandex Music {}", env!("CARGO_PKG_VERSION"))
};
vec![
StandardItem {
label: toggle_label.into(),
activate: Box::new(|this: &mut Self| {
let _ = this.tx.send(NativeEvent::ToggleWindow);
}),
..Default::default()
}
.into(),
StandardItem {
label: if self.is_ru {
"Проверить обновления".into()
} else {
"Check updates".into()
},
activate: Box::new(|this: &mut Self| {
let _ = this.tx.send(NativeEvent::CheckUpdates);
}),
..Default::default()
}
.into(),
MenuItem::Separator,
StandardItem {
label: play_label.into(),
activate: Box::new(|this: &mut Self| {
let _ = this.tx.send(NativeEvent::TogglePlay);
}),
..Default::default()
}
.into(),
StandardItem {
label: if self.is_ru {
"Предыдущий трек".into()
} else {
"Previous song".into()
},
activate: Box::new(|this: &mut Self| {
let _ = this.tx.send(NativeEvent::Prev);
}),
..Default::default()
}
.into(),
StandardItem {
label: if self.is_ru {
"Следующий трек".into()
} else {
"Next song".into()
},
activate: Box::new(|this: &mut Self| {
let _ = this.tx.send(NativeEvent::Next);
}),
..Default::default()
}
.into(),
MenuItem::Separator,
SubMenu {
label: if self.is_ru {
"О приложении".into()
} else {
"About the app".into()
},
submenu: vec![StandardItem {
label: ver_label,
enabled: false,
..Default::default()
}
.into()],
..Default::default()
}
.into(),
MenuItem::Separator,
StandardItem {
label: if self.is_ru {
"Закрыть приложение".into()
} else {
"Close app".into()
},
activate: Box::new(|this: &mut Self| {
let _ = this.tx.send(NativeEvent::QuitApp);
}),
..Default::default()
}
.into(),
]
}
}
fn decode_ksni_icon(png_bytes: &[u8]) -> Option<ksni::Icon> {
let img = image::load_from_memory(png_bytes).ok()?.to_rgba8();
let (w, h) = img.dimensions();
let mut data = img.into_raw();
for px in data.chunks_exact_mut(4) {
px.rotate_right(1); // RGBA -> ARGB32 network byte order (SNI spec)
}
Some(ksni::Icon {
width: w as i32,
height: h as i32,
data,
})
}
pub struct NativeDesktop {
handle: Option<Handle<LinuxTray>>,
rx: Receiver<NativeEvent>,
last_playing: Option<bool>,
last_track_id: Option<String>,
}
impl Drop for NativeDesktop {
fn drop(&mut self) {
if let Some(ref handle) = self.handle {
handle.shutdown();
}
}
}
impl NativeDesktop { impl NativeDesktop {
pub fn new(_window: &Window, _is_ru: bool) -> Self { pub fn new(_window: &Window, is_ru: bool) -> Self {
Self let (tx, rx) = unbounded();
let mut pixmaps = Vec::with_capacity(2);
if let Some(ic32) = decode_ksni_icon(include_bytes!("../../assets/icons/tray_32.png")) {
pixmaps.push(ic32);
}
if let Some(ic48) = decode_ksni_icon(include_bytes!("../../assets/icons/app_48.png")) {
pixmaps.push(ic48);
}
let tray = LinuxTray {
tx,
icons: Arc::new(pixmaps),
is_ru,
window_visible: true,
is_playing: false,
track_summary: String::new(),
};
let handle = tray.assume_sni_available(true).spawn().ok();
Self {
handle,
rx,
last_playing: None,
last_track_id: None,
}
} }
pub fn set_window_visible_label(&self, _visible: bool) {}
pub fn set_window_visible_label(&self, visible: bool) {
if let Some(ref handle) = self.handle {
handle.update(move |t| {
t.window_visible = visible;
});
}
}
pub fn poll_events(&self) -> Vec<NativeEvent> { pub fn poll_events(&self) -> Vec<NativeEvent> {
Vec::new() let mut out = Vec::new();
while let Ok(ev) = self.rx.try_recv() {
out.push(ev);
}
out
}
pub fn sync_playback(&mut self, track: Option<&Track>, is_playing: bool, _pos_ms: u64) {
let track_id = track.map(|t| t.id.as_str());
if self.last_playing == Some(is_playing) && self.last_track_id.as_deref() == track_id {
return;
}
self.last_playing = Some(is_playing);
self.last_track_id = track_id.map(String::from);
let summary = track
.map(|tr| {
let artists = tr.artists_string();
if artists.is_empty() {
tr.title.clone()
} else {
format!("{} — {}", artists, tr.title)
}
})
.unwrap_or_default();
if let Some(ref handle) = self.handle {
handle.update(move |t| {
t.is_playing = is_playing;
t.track_summary = summary;
});
}
} }
pub fn sync_playback(&mut self, _track: Option<&Track>, _is_playing: bool, _pos_ms: u64) {}
} }
pub fn load_window_icon() -> Option<winit::window::Icon> { pub fn load_window_icon() -> Option<winit::window::Icon> {

View file

@ -3812,7 +3812,7 @@ impl SplashPlayer {
/// Spawns a bounded 4-frame background WebP decoder selecting `splash_dark.webp` on `#000` /// Spawns a bounded 4-frame background WebP decoder selecting `splash_dark.webp` on `#000`
/// or `splash_light.webp` on `#FFF` to match official Yandex Music 5.129.0 SplashScreen 1-to-1! /// or `splash_light.webp` on `#FFF` to match official Yandex Music 5.129.0 SplashScreen 1-to-1!
pub fn spawn(is_dark: bool) -> Self { pub fn spawn(is_dark: bool) -> Self {
let (tx, rx) = crossbeam_channel::bounded::<SplashFrame>(4); let (tx, rx) = crossbeam_channel::bounded::<SplashFrame>(1);
std::thread::Builder::new() std::thread::Builder::new()
.name("ym-splash-decode".into()) .name("ym-splash-decode".into())
.spawn(move || { .spawn(move || {

View file

@ -80,42 +80,58 @@ pub fn render_sidebar(
} }
} }
// Collapse button on hover (`.NavbarDesktop_collapseButton`: 16×28px pill, 6px radius) // Exact 5.129.0 `.NavbarDesktop_collapseButton__XQh9d` (`f43a2cc01fed8ead.css:157-198`):
let sidebar_hovered = ctx.is_hovered(sidebar_rect); // - 16×28px pill (`width: 1rem`, `border-radius: 6px`), `margin-inline-end: -8px` overhanging
if sidebar_hovered { // right onto the sidebar/content seam on `ZLayer::Drawer` (`z-index: header`) so the content
let col_btn_rect = Rect::from_center_size( // card never clips its right half!
Pos2::new(sidebar_rect.right() - 8.0, sidebar_rect.top() + 22.0), // - Smooth 0.20s opacity fade on sidebar OR button hover; 16×16 `xxs` chevron inside;
Vec2::new(16.0, 28.0), // tooltip ("Развернуть"/"Expand") shown ONLY when collapsed (`enabled: s`).
); let col_btn_rect = Rect::from_center_size(
let col_resp = ctx.interact(WidgetId::new("sb_collapse"), col_btn_rect); Pos2::new(sidebar_rect.right(), sidebar_rect.top() + 20.0),
ctx.dl().push_rect( Vec2::new(16.0, 28.0),
col_btn_rect, );
6.0, let show_col_target =
if col_resp.hovered { !app.fullscreen_open && (ctx.is_hovered(sidebar_rect) || ctx.is_hovered(col_btn_rect));
let col_vis = ctx.animate_bool(WidgetId::new("sb_col_vis"), show_col_target, 0.20);
if col_vis > 0.01 {
ctx.with_layer(ZLayer::Drawer, |ctx| {
let col_resp = ctx.interact(WidgetId::new("sb_collapse"), col_btn_rect);
let bg_col = if col_resp.hovered {
pal.surface_hover pal.surface_hover
} else { } else {
pal.surface_secondary pal.surface_secondary
}, }
); .scale_alpha(col_vis);
ctx.draw_icon( let icon_col = if col_resp.hovered {
if collapsed {
Icon::ArrowRightXxs
} else {
Icon::ArrowLeftXxs
},
Rect::from_center_size(col_btn_rect.center(), Vec2::splat(20.0)),
if col_resp.hovered {
pal.text_primary pal.text_primary
} else { } else {
pal.text_secondary Color::rgb(0x80, 0x80, 0x80)
}, }
); .scale_alpha(col_vis);
if col_resp.hovered {
ctx.set_cursor(CursorKind::Pointer); ctx.dl().push_rect(col_btn_rect, 6.0, bg_col);
} ctx.draw_icon(
if col_resp.clicked { if collapsed {
actions.push(AppAction::ToggleSidebarCollapse); Icon::ArrowRightXxs
} } else {
Icon::ArrowLeftXxs
},
Rect::from_center_size(col_btn_rect.center(), Vec2::splat(16.0)),
icon_col,
);
if col_resp.hovered {
ctx.set_cursor(CursorKind::Pointer);
if collapsed {
ctx.show_tooltip(
col_btn_rect,
if ru { "Развернуть" } else { "Expand" },
);
}
}
if col_resp.clicked {
actions.push(AppAction::ToggleSidebarCollapse);
}
});
} }
// 2. Navigation Items (exact 5.129.0 order + optional Kids section) // 2. Navigation Items (exact 5.129.0 order + optional Kids section)