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/queue.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/queue.rs') diff --git a/src/queue.rs b/src/queue.rs index 2c20356..d42203f 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -117,6 +117,22 @@ impl Track { format!("{:0width$}. {} - {}", index + 1, album_artist, title) } } + + pub fn format(&self, format_str: &str) -> String { + let artist = self.artist.clone().unwrap_or_default(); + let album = self.album.clone().unwrap_or_default(); + let title = self.title.clone().unwrap_or_else(|| { + self.path + .file_name() + .and_then(|n| n.to_str()) + .unwrap_or("Unknown") + .to_string() + }); + format_str + .replace("$ARTIST", &artist) + .replace("$ALBUM", &album) + .replace("$TRACK", &title) + } } pub struct Queue { -- cgit v1.2.3