diff --git a/Cargo.toml b/Cargo.toml index c81c530..427106f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,3 +31,6 @@ chrono = "0.4.39" [patch.crates-io] winit = { path = "../winit" } + +[profile.release] +debug = true diff --git a/src/bar/mod.rs b/src/bar/mod.rs index 1f71fe4..389ccf6 100644 --- a/src/bar/mod.rs +++ b/src/bar/mod.rs @@ -4,11 +4,16 @@ use cushy::{ Size, }, kludgine::app::winit::{platform::wayland::Anchor, window::WindowLevel}, + styles::components::{ + BaseLineHeight, BaseTextSize, CornerRadius, DefaultBackgroundColor, FontWeight, + }, value::Dynamic, widget::MakeWidget, Application, Open, }; +use crate::theme::{BG_DEFAULT, CORNER_RADIUS, DEFAULT_FONT_WEIGHT, TEXT_SIZE}; + mod spotify; mod time; @@ -23,6 +28,11 @@ pub fn start_bar(app: &mut impl Application) -> cushy::Result { .centered() .expand_horizontally() .height(Lp::points(30)) + .with(&BaseTextSize, TEXT_SIZE) + .with(&BaseLineHeight, TEXT_SIZE) + .with(&DefaultBackgroundColor, BG_DEFAULT) + .with(&CornerRadius, CORNER_RADIUS) + .with(&FontWeight, DEFAULT_FONT_WEIGHT) .into_window() .inner_size(size.clone()) .titled("rshell") diff --git a/src/bar/spotify.rs b/src/bar/spotify.rs index 0381fee..4e54021 100644 --- a/src/bar/spotify.rs +++ b/src/bar/spotify.rs @@ -6,15 +6,15 @@ use std::{ use crate::{ rt::tokio_runtime, - theme::{BG_DEFAULT, CORNER_RADIUS, TEXT_SPOTIFY}, + theme::{BG_DEFAULT, CORNER_RADIUS, TEXT_SPOTIFY, WIDGET_PADDING}, vibrancy::Vibrancy, }; use cushy::{ figures::{units::Lp, Size, Zero}, kludgine::{AnyTexture, LazyTexture}, styles::{ - components::{FontWeight, LineHeight, TextColor, TextSize, WidgetBackground}, - Color, CornerRadii, Dimension, DimensionRange, Weight, + components::{TextColor, WidgetBackground}, + Color, CornerRadii, Dimension, DimensionRange, }, value::{Destination, Dynamic, Source}, widget::MakeWidget, @@ -25,7 +25,7 @@ use image::{self, imageops::FilterType, Rgb}; use mpris::{LoopStatus, PlaybackStatus, PlayerFinder}; use reqwest::Client; use reqwest_middleware::ClientBuilder; -use tokio::{runtime, task::JoinHandle}; +use tokio::task::JoinHandle; #[derive(PartialEq)] struct PlayingTrack { @@ -43,8 +43,8 @@ struct PlayingTrack { /// Renders spotify control widget, the small one pub fn spotify_controls() -> impl MakeWidget { - let (progress, track) = get_track_dynamics(); - let (texture, vibrancy) = get_texture_dynamic(track.clone()); + let (_progress, track) = get_track_dynamics(); + let (texture, _vibrancy) = get_texture_dynamic(track.clone()); const IMAGE_SIDE: i32 = 10 /* lineheight */ + 2 * 6 /* padding */; let image_size = Size::squared(DimensionRange::from(Dimension::Lp(Lp::points(IMAGE_SIDE)))); @@ -73,11 +73,11 @@ pub fn spotify_controls() -> impl MakeWidget { }) .into_label() .with(&TextColor, TEXT_SPOTIFY) - .with(&FontWeight, Weight::BOLD) - .with(&TextSize, Dimension::Lp(Lp::points(8))) - .with(&LineHeight, Dimension::Lp(Lp::points(10))) + // .with(&FontWeight, Weight::BOLD) + // .with(&TextSize, TEXT_SIZE) + // .with(&LineHeight, TEXT_SIZE) .centered() - .pad(), + .pad_by(WIDGET_PADDING), ) .into_columns() .with(&WidgetBackground, BG_DEFAULT) diff --git a/src/bar/time.rs b/src/bar/time.rs index 06d8033..fd07d22 100644 --- a/src/bar/time.rs +++ b/src/bar/time.rs @@ -7,11 +7,11 @@ use cushy::{ use crate::{ rt::tokio_runtime, - theme::{BG_DEFAULT, TEXT_CLOCK}, + theme::{BG_DEFAULT, TEXT_CLOCK, WIDGET_PADDING}, }; -const FORMAT: &'static str = " %H:%M %p 󰃭 %a %d"; -const FORMAT_ALT: &'static str = " %H:%M  %b %Y"; +const FORMAT: &'static str = " %H:%M %p 󰃭 %a %d "; +const FORMAT_ALT: &'static str = " %H:%M  %b %Y "; const CLOCK_ICONS: [&'static str; 12] = ["", "", "", "", "", "", "", "", "", "", "", ""]; @@ -39,10 +39,11 @@ pub fn time_widget() -> impl MakeWidget { false => (&CLOCK_ICONS, FORMAT), }; let icon = icon_set[current_time.hour12().1 as usize % 12].to_string(); + let icon = " ".to_string() + &icon; icon + ¤t_time.format(format).to_string() }) .with(&TextColor, TEXT_CLOCK) - .pad() + .pad_by(WIDGET_PADDING) .centered() .with(&WidgetBackground, BG_DEFAULT) } diff --git a/src/main.rs b/src/main.rs index 3d64776..b7b10aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use bar::start_bar; use clap::Parser; use cli::{Args, Commands}; -use cushy::{PendingApp, Run, TokioRuntime}; +use cushy::{Open, PendingApp, Run, TokioRuntime}; use menu::start_menu; mod bar; @@ -18,7 +18,13 @@ fn main() -> cushy::Result { app.on_startup(move |app| match args.cmd { Commands::Bar => start_bar(app).unwrap(), Commands::Menu => start_menu(app).unwrap(), - Commands::Power => todo!(), + Commands::Power => { + let win = "Hello world!".open(app).unwrap(); + // std::thread::spawn(move || { + // std::thread::sleep(std::time::Duration::from_secs(2)); + // win.request_close(); + // }); + } }); // Ok(()) diff --git a/src/theme.rs b/src/theme.rs index 410ec28..5b8d3f2 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -1,9 +1,18 @@ use cushy::{ - figures::units::Lp, - styles::{Color, Dimension}, + figures::units::Px, + styles::{Color, Dimension, Edges, Weight}, }; -pub const CORNER_RADIUS: Dimension = Dimension::Lp(Lp::points(6)); +pub const CORNER_RADIUS: Dimension = Dimension::Px(Px::new(10)); +pub const TEXT_SIZE: Dimension = Dimension::Px(Px::new(13)); +pub const WIDGET_PADDING: Edges = Edges { + left: Dimension::Px(Px::new(6)), + right: Dimension::Px(Px::new(6)), + top: Dimension::Px(Px::new(3)), + bottom: Dimension::Px(Px::new(3)), +}; + +pub const DEFAULT_FONT_WEIGHT: Weight = Weight::BOLD; pub const BG_DEFAULT: Color = Color(0x191724FF); pub const TEXT_SPOTIFY: Color = Color(0x1DB954FF);