aboutsummaryrefslogtreecommitdiffstats
path: root/src/notification.rs
blob: 2f7baa2ce9fdf5c9d649a31aa3bf187fbf7e7b44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use crate::queue::Track;

pub fn notify_track(track: &Track) {
    let body = match (track.artist.as_deref(), track.title.as_deref()) {
        (Some(a), Some(t)) => format!("{} - {}", a, t),
        (_, Some(t)) => t.to_string(),
        _ => track
            .path
            .file_name()
            .and_then(|n| n.to_str())
            .unwrap_or("Unknown")
            .to_string(),
    };

    let _ = notify_rust::Notification::new()
        .summary("Now Playing")
        .body(&body)
        .appname("rsp")
        .show();
}

pub fn notify_queue_ended() {
    let _ = notify_rust::Notification::new()
        .summary("Playback Ended")
        .body("The queue is empty")
        .appname("rsp")
        .show();
}

pub fn notify_error(context: &str) {
    let _ = notify_rust::Notification::new()
        .summary("rsp Error")
        .body(&format!("{} - Check the logs for details", context))
        .appname("rsp")
        .show();
}