mirror of
https://github.com/danbulant/rshell
synced 2026-07-05 11:10:41 +00:00
small improv
This commit is contained in:
parent
2f272b026f
commit
64fba908ac
6 changed files with 48 additions and 19 deletions
|
|
@ -31,3 +31,6 @@ chrono = "0.4.39"
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
winit = { path = "../winit" }
|
winit = { path = "../winit" }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
debug = true
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,16 @@ use cushy::{
|
||||||
Size,
|
Size,
|
||||||
},
|
},
|
||||||
kludgine::app::winit::{platform::wayland::Anchor, window::WindowLevel},
|
kludgine::app::winit::{platform::wayland::Anchor, window::WindowLevel},
|
||||||
|
styles::components::{
|
||||||
|
BaseLineHeight, BaseTextSize, CornerRadius, DefaultBackgroundColor, FontWeight,
|
||||||
|
},
|
||||||
value::Dynamic,
|
value::Dynamic,
|
||||||
widget::MakeWidget,
|
widget::MakeWidget,
|
||||||
Application, Open,
|
Application, Open,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::theme::{BG_DEFAULT, CORNER_RADIUS, DEFAULT_FONT_WEIGHT, TEXT_SIZE};
|
||||||
|
|
||||||
mod spotify;
|
mod spotify;
|
||||||
mod time;
|
mod time;
|
||||||
|
|
||||||
|
|
@ -23,6 +28,11 @@ pub fn start_bar(app: &mut impl Application) -> cushy::Result {
|
||||||
.centered()
|
.centered()
|
||||||
.expand_horizontally()
|
.expand_horizontally()
|
||||||
.height(Lp::points(30))
|
.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()
|
.into_window()
|
||||||
.inner_size(size.clone())
|
.inner_size(size.clone())
|
||||||
.titled("rshell")
|
.titled("rshell")
|
||||||
|
|
|
||||||
|
|
@ -6,15 +6,15 @@ use std::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
rt::tokio_runtime,
|
rt::tokio_runtime,
|
||||||
theme::{BG_DEFAULT, CORNER_RADIUS, TEXT_SPOTIFY},
|
theme::{BG_DEFAULT, CORNER_RADIUS, TEXT_SPOTIFY, WIDGET_PADDING},
|
||||||
vibrancy::Vibrancy,
|
vibrancy::Vibrancy,
|
||||||
};
|
};
|
||||||
use cushy::{
|
use cushy::{
|
||||||
figures::{units::Lp, Size, Zero},
|
figures::{units::Lp, Size, Zero},
|
||||||
kludgine::{AnyTexture, LazyTexture},
|
kludgine::{AnyTexture, LazyTexture},
|
||||||
styles::{
|
styles::{
|
||||||
components::{FontWeight, LineHeight, TextColor, TextSize, WidgetBackground},
|
components::{TextColor, WidgetBackground},
|
||||||
Color, CornerRadii, Dimension, DimensionRange, Weight,
|
Color, CornerRadii, Dimension, DimensionRange,
|
||||||
},
|
},
|
||||||
value::{Destination, Dynamic, Source},
|
value::{Destination, Dynamic, Source},
|
||||||
widget::MakeWidget,
|
widget::MakeWidget,
|
||||||
|
|
@ -25,7 +25,7 @@ use image::{self, imageops::FilterType, Rgb};
|
||||||
use mpris::{LoopStatus, PlaybackStatus, PlayerFinder};
|
use mpris::{LoopStatus, PlaybackStatus, PlayerFinder};
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use reqwest_middleware::ClientBuilder;
|
use reqwest_middleware::ClientBuilder;
|
||||||
use tokio::{runtime, task::JoinHandle};
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
struct PlayingTrack {
|
struct PlayingTrack {
|
||||||
|
|
@ -43,8 +43,8 @@ struct PlayingTrack {
|
||||||
|
|
||||||
/// Renders spotify control widget, the small one
|
/// Renders spotify control widget, the small one
|
||||||
pub fn spotify_controls() -> impl MakeWidget {
|
pub fn spotify_controls() -> impl MakeWidget {
|
||||||
let (progress, track) = get_track_dynamics();
|
let (_progress, track) = get_track_dynamics();
|
||||||
let (texture, vibrancy) = get_texture_dynamic(track.clone());
|
let (texture, _vibrancy) = get_texture_dynamic(track.clone());
|
||||||
|
|
||||||
const IMAGE_SIDE: i32 = 10 /* lineheight */ + 2 * 6 /* padding */;
|
const IMAGE_SIDE: i32 = 10 /* lineheight */ + 2 * 6 /* padding */;
|
||||||
let image_size = Size::squared(DimensionRange::from(Dimension::Lp(Lp::points(IMAGE_SIDE))));
|
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()
|
.into_label()
|
||||||
.with(&TextColor, TEXT_SPOTIFY)
|
.with(&TextColor, TEXT_SPOTIFY)
|
||||||
.with(&FontWeight, Weight::BOLD)
|
// .with(&FontWeight, Weight::BOLD)
|
||||||
.with(&TextSize, Dimension::Lp(Lp::points(8)))
|
// .with(&TextSize, TEXT_SIZE)
|
||||||
.with(&LineHeight, Dimension::Lp(Lp::points(10)))
|
// .with(&LineHeight, TEXT_SIZE)
|
||||||
.centered()
|
.centered()
|
||||||
.pad(),
|
.pad_by(WIDGET_PADDING),
|
||||||
)
|
)
|
||||||
.into_columns()
|
.into_columns()
|
||||||
.with(&WidgetBackground, BG_DEFAULT)
|
.with(&WidgetBackground, BG_DEFAULT)
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,11 @@ use cushy::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
rt::tokio_runtime,
|
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: &'static str = " %H:%M %p %a %d ";
|
||||||
const FORMAT_ALT: &'static str = " %H:%M %b %Y";
|
const FORMAT_ALT: &'static str = " %H:%M %b %Y ";
|
||||||
|
|
||||||
const CLOCK_ICONS: [&'static str; 12] =
|
const CLOCK_ICONS: [&'static str; 12] =
|
||||||
["", "", "", "", "", "", "", "", "", "", "", ""];
|
["", "", "", "", "", "", "", "", "", "", "", ""];
|
||||||
|
|
@ -39,10 +39,11 @@ pub fn time_widget() -> impl MakeWidget {
|
||||||
false => (&CLOCK_ICONS, FORMAT),
|
false => (&CLOCK_ICONS, FORMAT),
|
||||||
};
|
};
|
||||||
let icon = icon_set[current_time.hour12().1 as usize % 12].to_string();
|
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()
|
icon + ¤t_time.format(format).to_string()
|
||||||
})
|
})
|
||||||
.with(&TextColor, TEXT_CLOCK)
|
.with(&TextColor, TEXT_CLOCK)
|
||||||
.pad()
|
.pad_by(WIDGET_PADDING)
|
||||||
.centered()
|
.centered()
|
||||||
.with(&WidgetBackground, BG_DEFAULT)
|
.with(&WidgetBackground, BG_DEFAULT)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -1,7 +1,7 @@
|
||||||
use bar::start_bar;
|
use bar::start_bar;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::{Args, Commands};
|
use cli::{Args, Commands};
|
||||||
use cushy::{PendingApp, Run, TokioRuntime};
|
use cushy::{Open, PendingApp, Run, TokioRuntime};
|
||||||
use menu::start_menu;
|
use menu::start_menu;
|
||||||
|
|
||||||
mod bar;
|
mod bar;
|
||||||
|
|
@ -18,7 +18,13 @@ fn main() -> cushy::Result {
|
||||||
app.on_startup(move |app| match args.cmd {
|
app.on_startup(move |app| match args.cmd {
|
||||||
Commands::Bar => start_bar(app).unwrap(),
|
Commands::Bar => start_bar(app).unwrap(),
|
||||||
Commands::Menu => start_menu(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(())
|
// Ok(())
|
||||||
|
|
|
||||||
15
src/theme.rs
15
src/theme.rs
|
|
@ -1,9 +1,18 @@
|
||||||
use cushy::{
|
use cushy::{
|
||||||
figures::units::Lp,
|
figures::units::Px,
|
||||||
styles::{Color, Dimension},
|
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<Dimension> = 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 BG_DEFAULT: Color = Color(0x191724FF);
|
||||||
pub const TEXT_SPOTIFY: Color = Color(0x1DB954FF);
|
pub const TEXT_SPOTIFY: Color = Color(0x1DB954FF);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue