diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/git_toolbox_blame.xml b/.idea/git_toolbox_blame.xml new file mode 100644 index 0000000..7dc1249 --- /dev/null +++ b/.idea/git_toolbox_blame.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..aca4ccd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rshell.iml b/.idea/rshell.iml new file mode 100644 index 0000000..cf84ae4 --- /dev/null +++ b/.idea/rshell.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 683c325..5653f8f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -203,9 +203,9 @@ dependencies = [ [[package]] name = "ashpd" -version = "0.9.1" +version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfe7e0dd0ac5a401dc116ed9f9119cf9decc625600474cb41f0fc0a0050abc9a" +checksum = "4d43c03d9e36dd40cab48435be0b09646da362c278223ca535493877b2c1dee9" dependencies = [ "async-fs", "async-net", @@ -665,9 +665,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.28" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" dependencies = [ "jobserver", "libc", @@ -920,7 +920,7 @@ checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991" [[package]] name = "cushy" version = "0.4.0" -source = "git+https://github.com/khonsulabs/cushy.git?branch=main#b0a870aceb5e61992dc02382a9334b7b32049e01" +source = "git+https://github.com/khonsulabs/cushy.git?branch=main#ab474e2b7dbe9a178f7038243adc213e1a292d99" dependencies = [ "ahash", "alot", @@ -950,7 +950,7 @@ dependencies = [ [[package]] name = "cushy-macros" version = "0.4.0" -source = "git+https://github.com/khonsulabs/cushy.git?branch=main#b0a870aceb5e61992dc02382a9334b7b32049e01" +source = "git+https://github.com/khonsulabs/cushy.git?branch=main#ab474e2b7dbe9a178f7038243adc213e1a292d99" dependencies = [ "attribute-derive", "manyhow", @@ -2083,9 +2083,9 @@ checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -4703,9 +4703,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -4714,9 +4714,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -4729,9 +4729,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -4741,9 +4741,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote 1.0.37", "wasm-bindgen-macro-support", @@ -4751,9 +4751,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote 1.0.37", @@ -4764,9 +4764,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wayland-backend" @@ -4879,9 +4879,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 292fe49..11615d0 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,3 @@ [toolchain] channel = "stable" +components = ["rust-src"] \ No newline at end of file diff --git a/src/bar/mod.rs b/src/bar/mod.rs new file mode 100644 index 0000000..34c4e85 --- /dev/null +++ b/src/bar/mod.rs @@ -0,0 +1,19 @@ +use cushy::{kludgine::app::winit::window::WindowLevel, widget::MakeWidget, Application, Open}; + +mod spotify; + +pub fn start_bar(app: &mut impl Application) -> cushy::Result { + let mut window = spotify::spotify_controls() + .pad() + .into_window() + .transparent() + .app_name("rshell") + .decorated(false) + // .resizable(false) + .window_level(WindowLevel::AlwaysOnTop); + + window.sans_serif_font_family.push(cushy::styles::FamilyOwned::Name("Iosevka NF".into())); + + window + .open(app).map(|_| ()) +} \ No newline at end of file diff --git a/src/spotify.rs b/src/bar/spotify.rs similarity index 85% rename from src/spotify.rs rename to src/bar/spotify.rs index 8287218..e9de004 100644 --- a/src/spotify.rs +++ b/src/bar/spotify.rs @@ -2,12 +2,12 @@ use std::{sync::{Arc, Mutex}, thread, time::Duration}; use http_cache_reqwest::{CACacheManager, Cache, CacheMode, HttpCache, HttpCacheOptions}; use mpris::{LoopStatus, PlaybackStatus, PlayerFinder}; -use cushy::{figures::{units::Lp, Size}, kludgine::{AnyTexture, LazyTexture}, styles::{components::WidgetBackground, Color, Dimension, DimensionRange}, value::{Destination, Dynamic, IntoReader, Source}, widget::MakeWidget, widgets::{image::ImageCornerRadius, Image}}; +use cushy::{figures::{units::Lp, Size, Zero}, kludgine::{AnyTexture, LazyTexture}, styles::{components::{FontWeight, TextColor, WidgetBackground}, Color, CornerRadii, Dimension, DimensionRange, Weight}, value::{Destination, Dynamic, IntoReader, Source}, widget::MakeWidget, widgets::{image::ImageCornerRadius, Image}}; use reqwest::Client; use reqwest_middleware::ClientBuilder; -use image::{self, Rgb}; +use image::{self, imageops::FilterType, Rgb}; use tokio::{runtime, task::JoinHandle}; -use crate::vibrancy::Vibrancy; +use crate::{theme::{BG_DEFAULT, TEXT_SPOTIFY}, vibrancy::Vibrancy}; #[derive(PartialEq)] struct PlayingTrack { @@ -28,13 +28,20 @@ pub fn spotify_controls() -> impl MakeWidget { let (progress, track) = get_track_dynamics(); let (texture, vibrancy) = get_texture_dynamic(track.clone()); - const IMAGE_SIZE: i32 = 16 /* lineheight */ + 2 * 6 /* padding */ + 8; // Why the 8 there? I don't know, but it works. + const IMAGE_SIDE: i32 = 16 /* lineheight */ + 2 * 6 /* padding */; + let image_size = Size::squared(DimensionRange::from(Dimension::Lp(Lp::points(IMAGE_SIDE)))); + const CORNER_RADIUS: Dimension = Dimension::Lp(Lp::points(6)); Image::new(texture) .aspect_fit() - // .with(&ImageCornerRadius, Lp::points(6)) + .with(&ImageCornerRadius, CornerRadii { + top_left: CORNER_RADIUS, + top_right: Dimension::ZERO, + bottom_left: CORNER_RADIUS, + bottom_right: Dimension::ZERO, + }) // default pad is 6, default line height is 16 - .size(Size::new(DimensionRange::from(Dimension::Lp(Lp::points(IMAGE_SIZE))), DimensionRange::from(Dimension::Lp(Lp::points(IMAGE_SIZE))))) + .size(image_size) .and( track.map_each(|track| { if let Some(track) = track { @@ -48,12 +55,14 @@ pub fn spotify_controls() -> impl MakeWidget { } }) .to_label() + .with(&TextColor, TEXT_SPOTIFY) + .with(&FontWeight, Weight::BOLD) .centered() .pad() ) .into_columns() - .with(&WidgetBackground, Color::CLEAR_WHITE) // vibrancy.map_each(|vib| vib.muted.unwrap_or(Color::BLACK).into())) - // .size(Size::new(DimensionRange::default(), DimensionRange::from(Dimension::Lp(Lp::points(28))))) + .with(&WidgetBackground, BG_DEFAULT) + // .with(&WidgetBackground, vibrancy.map_each(|vib| vib.primary.unwrap_or(Color::BLACK).into())) } fn get_empty_texture() -> AnyTexture { @@ -132,6 +141,7 @@ fn get_texture_dynamic(track: Dynamic>) -> (Dynamic>) -> (Dynamic cushy::Result { let mut app = PendingApp::new(TokioRuntime::default()); - - - spotify::spotify_controls() - .centered() - .with(&DefaultBackgroundColor, Color::CLEAR_WHITE) - .into_window() - .transparent() - .app_name("rshell") - .open(&mut app)?; + start_bar(&mut app)?; app.run() } \ No newline at end of file diff --git a/src/theme.rs b/src/theme.rs new file mode 100644 index 0000000..2c946f8 --- /dev/null +++ b/src/theme.rs @@ -0,0 +1,5 @@ +use cushy::styles::Color; + + +pub const TEXT_SPOTIFY: Color = Color(0x1DB954FF); +pub const BG_DEFAULT: Color = Color(0x191724FF); \ No newline at end of file