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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/*
* This file is a part of RSPlayer
* Licensed under the GPL-3.0 License
* Copyright (C) 2026 Salmonik @ salmonik@tuta.io
* https://codeberg.org/salmonik/RSPlayer
*/
use crate::queue::Track;
pub fn notify_track(track: &Track, format: Option<&str>) {
let body = match format {
Some(fmt) => track.format(fmt),
None => 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("RSPlayer")
.show();
}
pub fn notify_queue_ended() {
let _ = notify_rust::Notification::new()
.summary("Playback Ended")
.body("The queue is empty")
.appname("RSPlayer")
.show();
}
pub fn notify_change(state: &str) {
let _ = notify_rust::Notification::new()
.summary(state)
.body(&format!("Playback {}", state.to_lowercase()))
.appname("RSPlayer")
.show();
}
pub fn notify_error(context: &str) {
let _ = notify_rust::Notification::new()
.summary("RSPlayer Error")
.body(&format!("{} - Check the logs for details", context))
.appname("RSPlayer")
.show();
}
pub fn notify(summary: &str, body: &str) {
let _ = notify_rust::Notification::new()
.summary(summary)
.body(body)
.appname("RSPlayer")
.show();
}
|