aboutsummaryrefslogtreecommitdiffstats
path: root/src/notification.rs
diff options
context:
space:
mode:
authorsalmonik <raisersoft@proton.me>2026-05-11 16:25:49 +0200
committersalmonik <raisersoft@proton.me>2026-05-11 16:25:49 +0200
commit455ec54613230f4004a24f8d2798fb0084e00cb4 (patch)
tree5ffb7606a11ebf33ea940f068ed046bfda0f0c54 /src/notification.rs
parentFix shuffle to not shuffle current track - only shuffle tracks after current ... (diff)
downloadrsplayer-455ec54613230f4004a24f8d2798fb0084e00cb4.tar.gz
rsplayer-455ec54613230f4004a24f8d2798fb0084e00cb4.zip
Add display_format config, fix restart command, clean up config code
- Add display_format option with get/set/list/unset for customizing track display - Add Track::format() supporting $ARTIST, $ALBUM, $TRACK variables - Update queue, status, notifications to use display_format - Fix restart command using wrong subcommand 'start' -> 'start-daemon' - Remove socket_path from config (now computed at runtime from XDG_RUNTIME_DIR) - Consolidate duplicate save() and save_all() into single save() - Fix redundant .clone().clone() in config.rs - Add todo item for caching config in daemon hot paths
Diffstat (limited to '')
-rw-r--r--src/notification.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/notification.rs b/src/notification.rs
index 2f7baa2..4947e6f 100644
--- a/src/notification.rs
+++ b/src/notification.rs
@@ -1,15 +1,18 @@
1use crate::queue::Track; 1use crate::queue::Track;
2 2
3pub fn notify_track(track: &Track) { 3pub fn notify_track(track: &Track, format: Option<&str>) {
4 let body = match (track.artist.as_deref(), track.title.as_deref()) { 4 let body = match format {
5 (Some(a), Some(t)) => format!("{} - {}", a, t), 5 Some(fmt) => track.format(fmt),
6 (_, Some(t)) => t.to_string(), 6 None => match (track.artist.as_deref(), track.title.as_deref()) {
7 _ => track 7 (Some(a), Some(t)) => format!("{} - {}", a, t),
8 .path 8 (_, Some(t)) => t.to_string(),
9 .file_name() 9 _ => track
10 .and_then(|n| n.to_str()) 10 .path
11 .unwrap_or("Unknown") 11 .file_name()
12 .to_string(), 12 .and_then(|n| n.to_str())
13 .unwrap_or("Unknown")
14 .to_string(),
15 },
13 }; 16 };
14 17
15 let _ = notify_rust::Notification::new() 18 let _ = notify_rust::Notification::new()