diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-11 16:25:49 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-11 16:25:49 +0200 |
| commit | 455ec54613230f4004a24f8d2798fb0084e00cb4 (patch) | |
| tree | 5ffb7606a11ebf33ea940f068ed046bfda0f0c54 /src/queue.rs | |
| parent | Fix shuffle to not shuffle current track - only shuffle tracks after current ... (diff) | |
| download | rsplayer-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/queue.rs | 16 |
1 files changed, 16 insertions, 0 deletions
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 { | |||
| 117 | format!("{:0width$}. {} - {}", index + 1, album_artist, title) | 117 | format!("{:0width$}. {} - {}", index + 1, album_artist, title) |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | |||
| 121 | pub fn format(&self, format_str: &str) -> String { | ||
| 122 | let artist = self.artist.clone().unwrap_or_default(); | ||
| 123 | let album = self.album.clone().unwrap_or_default(); | ||
| 124 | let title = self.title.clone().unwrap_or_else(|| { | ||
| 125 | self.path | ||
| 126 | .file_name() | ||
| 127 | .and_then(|n| n.to_str()) | ||
| 128 | .unwrap_or("Unknown") | ||
| 129 | .to_string() | ||
| 130 | }); | ||
| 131 | format_str | ||
| 132 | .replace("$ARTIST", &artist) | ||
| 133 | .replace("$ALBUM", &album) | ||
| 134 | .replace("$TRACK", &title) | ||
| 135 | } | ||
| 120 | } | 136 | } |
| 121 | 137 | ||
| 122 | pub struct Queue { | 138 | pub struct Queue { |
