Just pre implement the show notification function =|
This commit is contained in:
parent
3c37bcf9fb
commit
fdc1670fdc
1 changed files with 41 additions and 0 deletions
41
src/notification.rs
Normal file
41
src/notification.rs
Normal 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(())
|
||||
}
|
Loading…
Reference in a new issue