diff --git a/src/main.rs b/src/main.rs index df7775e..734fa91 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,3 @@ -use std::io::Cursor; - use mpris::PlayerFinder; use anyhow::Result; use tray_item::IconSource; @@ -10,26 +8,32 @@ fn main() -> Result<()> { let mut tracker = players[0].track_progress(500)?; - let icon = IconSource::Data{data: gen_icon(), height: 32, width: 32}; + let icon = IconSource::Data{data: gen_icon(0), height: 32, width: 32}; - let mut tray = TrayItem::new("funring", icon); + let mut tray = TrayItem::new("funring", icon)?; println!("Hello, {}!", players[0].identity()); loop { - let player = &players[0]; - let elapsed = player.get_position().unwrap().as_secs(); - let total = player.get_metadata().unwrap().length().unwrap().as_secs(); + let tick = tracker.tick(); + let elapsed = tick.progress.position().as_secs(); + let total = tick.progress.length().unwrap().as_secs(); println!("{elapsed}s/{total}s!"); + let prog = elapsed as f32 / total as f32 * 256.0; + println!("{prog}"); + + tray.set_icon( + IconSource::Data{data: gen_icon(prog as u8), height: 32, width: 32} + )?; } } -fn gen_icon() -> Vec { +fn gen_icon(red: u8) -> Vec { let mut icon = Vec::new(); for pix in 0..(32*32) { - icon.push(0); - icon.push(0); - icon.push(255); icon.push(1); + icon.push(red); + icon.push(0); + icon.push(0); } icon }