Just pre implement the show notification function =|

This commit is contained in:
Anas Elgarhy 2023-02-14 19:10:47 +02:00
parent 3c37bcf9fb
commit fdc1670fdc
No known key found for this signature in database
GPG key ID: 0501802A1D496528

41
src/notification.rs Normal file
View file

@ -0,0 +1,41 @@
use crate::cmus::events::CmusEvent;
use crate::settings::Settings;
use crate::TrackCover;
#[inline(always)]
pub fn show_notification(events: Vec<CmusEvent>, settings: &Settings, previous_cover: &mut TrackCover) -> Result<(), notify_rust::error::Error> {
if events.is_empty() {
return Ok(()); // No events to process.
}
let mut notification = notify_rust::Notification::new();
for event in events {
match event {
CmusEvent::StatusChanged(status) => {
println!("{:?}", status);
}
CmusEvent::TrackChanged(track) => {
println!("track change {:?}", track);
}
CmusEvent::VolumeChanged { left, right } if settings.show_player_notifications => {
println!("left: {}, right: {}", left, right);
}
CmusEvent::PositionChanged(position) => {
println!("position: {}", position);
}
CmusEvent::ShuffleChanged(shuffle) if settings.show_player_notifications => {
println!("shuffle: {:?}", shuffle);
}
CmusEvent::RepeatChanged(repeat) if settings.show_player_notifications => {
println!("repeat: {}", repeat);
}
CmusEvent::AAAMode(aaa_mode) if settings.show_player_notifications => {
println!("aaa_mode: {:?}", aaa_mode);
}
_ => {}
}
notification.show()?;
}
Ok(())
}