colors in my statusbar
This commit is contained in:
parent
91b6299091
commit
2aba7e33c1
3 changed files with 122 additions and 1882 deletions
1953
Cargo.lock
generated
1953
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,8 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
gtk = "0.18.1"
|
||||
mpris = "2.0.1"
|
||||
tray-icon = "0.10.0"
|
||||
winit = "0.29.3"
|
||||
|
||||
[dependencies.tray-item]
|
||||
git = "https://github.com/olback/tray-item-rs.git"
|
||||
features = [ "ksni" ]
|
||||
|
|
42
src/main.rs
42
src/main.rs
|
@ -1,52 +1,34 @@
|
|||
use std::io::Cursor;
|
||||
|
||||
use mpris::PlayerFinder;
|
||||
use anyhow::Result;
|
||||
use tray_icon::menu::Menu;
|
||||
use tray_icon::{TrayIconEvent, TrayIconBuilder, Icon};
|
||||
use winit::event_loop::EventLoopBuilder;
|
||||
use winit::event_loop::ControlFlow;
|
||||
use tray_item::IconSource;
|
||||
use tray_item::TrayItem;
|
||||
fn main() -> Result<()> {
|
||||
let pf = PlayerFinder::new()?;
|
||||
let players = pf.find_all()?;
|
||||
|
||||
let icon = Icon::from_rgba(gen_icon(), 32, 32)?;
|
||||
|
||||
// gtk thread
|
||||
std::thread::spawn(|| {
|
||||
gtk::init().unwrap();
|
||||
let tray_icon = TrayIconBuilder::new()
|
||||
.with_menu(Box::new(Menu::new()))
|
||||
.with_icon(icon).build()
|
||||
.unwrap();
|
||||
gtk::main();
|
||||
});
|
||||
|
||||
let mut tracker = players[0].track_progress(500)?;
|
||||
let tray_channel = TrayIconEvent::receiver();
|
||||
|
||||
let event_loop = EventLoopBuilder::new().build()?;
|
||||
let icon = IconSource::Data{data: gen_icon(), height: 32, width: 32};
|
||||
|
||||
let mut tray = TrayItem::new("funring", icon);
|
||||
|
||||
println!("Hello, {}!", players[0].identity());
|
||||
event_loop.run(move |event, event_loop| {
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
loop {
|
||||
let player = &players[0];
|
||||
let elapsed = player.get_position().unwrap().as_secs();
|
||||
let total = player.get_metadata().unwrap().length().unwrap().as_secs();
|
||||
//println!("{elapsed}s/{total}s!");
|
||||
|
||||
for event in tray_channel.try_iter() {
|
||||
println!("{:?}: event", event)
|
||||
println!("{elapsed}s/{total}s!");
|
||||
}
|
||||
})?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn gen_icon() -> Vec<u8> {
|
||||
let mut icon = Vec::new();
|
||||
for pix in 0..(32*32) {
|
||||
icon.push(1);
|
||||
icon.push(1);
|
||||
icon.push(1);
|
||||
icon.push(0);
|
||||
icon.push(0);
|
||||
icon.push(255);
|
||||
icon.push(1);
|
||||
}
|
||||
icon
|
||||
|
|
Loading…
Reference in a new issue