From 455ec54613230f4004a24f8d2798fb0084e00cb4 Mon Sep 17 00:00:00 2001 From: salmonik Date: Mon, 11 May 2026 16:25:49 +0200 Subject: 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 --- src/notification.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/notification.rs') 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 @@ 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(), +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() -- cgit v1.2.3