aboutsummaryrefslogtreecommitdiffstats
path: root/src/notification.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/notification.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/notification.rs b/src/notification.rs
new file mode 100644
index 0000000..2f7baa2
--- /dev/null
+++ b/src/notification.rs
@@ -0,0 +1,36 @@
1use crate::queue::Track;
2
3pub fn notify_track(track: &Track) {
4 let body = match (track.artist.as_deref(), track.title.as_deref()) {
5 (Some(a), Some(t)) => format!("{} - {}", a, t),
6 (_, Some(t)) => t.to_string(),
7 _ => track
8 .path
9 .file_name()
10 .and_then(|n| n.to_str())
11 .unwrap_or("Unknown")
12 .to_string(),
13 };
14
15 let _ = notify_rust::Notification::new()
16 .summary("Now Playing")
17 .body(&body)
18 .appname("rsp")
19 .show();
20}
21
22pub fn notify_queue_ended() {
23 let _ = notify_rust::Notification::new()
24 .summary("Playback Ended")
25 .body("The queue is empty")
26 .appname("rsp")
27 .show();
28}
29
30pub fn notify_error(context: &str) {
31 let _ = notify_rust::Notification::new()
32 .summary("rsp Error")
33 .body(&format!("{} - Check the logs for details", context))
34 .appname("rsp")
35 .show();
36}