rustfmt
This commit is contained in:
parent
4b5f44524c
commit
60061345fc
1 changed files with 27 additions and 27 deletions
34
src/main.rs
34
src/main.rs
|
@ -4,20 +4,24 @@ use std::collections::hash_map::DefaultHasher;
|
|||
use std::hash::Hash;
|
||||
use std::hash::Hasher;
|
||||
|
||||
use mpris::PlaybackStatus;
|
||||
use mpris::PlayerFinder;
|
||||
use anyhow::Result;
|
||||
use tray_item::IconSource;
|
||||
use tray_item::TrayItem;
|
||||
use glam::UVec2;
|
||||
use glam::Vec2;
|
||||
use mpris::PlaybackStatus;
|
||||
use mpris::PlayerFinder;
|
||||
use tray_item::IconSource;
|
||||
use tray_item::TrayItem;
|
||||
fn main() -> Result<()> {
|
||||
let pf = PlayerFinder::new()?;
|
||||
let players = pf.find_all()?;
|
||||
|
||||
let mut tracker = players[0].track_progress(25)?;
|
||||
|
||||
let icon = IconSource::Data{data: gen_icon(0.0, false), height: RES, width: RES};
|
||||
let icon = IconSource::Data {
|
||||
data: gen_icon(0.0, false),
|
||||
height: RES,
|
||||
width: RES,
|
||||
};
|
||||
|
||||
let mut tray = TrayItem::new("funring", icon)?;
|
||||
|
||||
|
@ -38,7 +42,11 @@ fn main() -> Result<()> {
|
|||
hasher.finish()
|
||||
};
|
||||
if !last_hash.replace(hash).is_some_and(|h| h == hash) {
|
||||
tray.set_icon(IconSource::Data{data: buffer, height: RES, width: RES})?;
|
||||
tray.set_icon(IconSource::Data {
|
||||
data: buffer,
|
||||
height: RES,
|
||||
width: RES,
|
||||
})?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +54,7 @@ fn main() -> Result<()> {
|
|||
const RES: i32 = 32;
|
||||
const LEN: usize = (RES * RES) as usize;
|
||||
|
||||
fn gen_icon(
|
||||
prog: f32,
|
||||
playing: bool,
|
||||
) -> Vec<u8> {
|
||||
fn gen_icon(prog: f32, playing: bool) -> Vec<u8> {
|
||||
let mut icon = vec![0; LEN * 4];
|
||||
for pix in 0..(LEN) {
|
||||
let x = pix % RES as usize;
|
||||
|
@ -58,19 +63,14 @@ fn gen_icon(
|
|||
UVec2::new(x as u32, y as u32),
|
||||
prog,
|
||||
playing,
|
||||
&mut icon[0..LEN*4]
|
||||
&mut icon[0..LEN * 4],
|
||||
);
|
||||
}
|
||||
icon
|
||||
}
|
||||
|
||||
// TODO: integrate rust-gpu
|
||||
fn icon_cs(
|
||||
idx: UVec2,
|
||||
progress: f32,
|
||||
playing: bool,
|
||||
buf: &mut [u8],
|
||||
) {
|
||||
fn icon_cs(idx: UVec2, progress: f32, playing: bool, buf: &mut [u8]) {
|
||||
let index = (idx.y * RES as u32 + idx.x) as usize;
|
||||
let pix = &mut buf[4 * index..4 * index + 4];
|
||||
pix[0] = 1;
|
||||
|
|
Loading…
Reference in a new issue