From b3b7f0f65295f2100eb3c9880e870349c43701a6 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sat, 9 May 2026 15:14:33 +0200 Subject: Major rewrite: play command, queue display, and shuffle modes - Play command: no args queues to end (play only if queue empty + player playing), -i inserts after current and skips, -n inserts after current, removed -l flag - Queue display: detect terminal size, use pager only if queue exceeds terminal rows - Shuffle modes: always remember original queue, restore on 'shuffle none', album shuffle shuffles within each album's range separately --- src/daemon.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/daemon.rs') diff --git a/src/daemon.rs b/src/daemon.rs index e88669a..f4a72b7 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -399,9 +399,9 @@ fn process_command( format!("Queued next: {}\n", path_str) } _ => { - let was_playing = audio.is_playing(); + let was_empty = q.is_empty(); q.add_track(path.clone()); - if !was_playing { + if was_empty && audio.is_playing() { let track = Track::from_path(path.clone()); audio.play(path); notification::notify_track(&track); @@ -452,7 +452,8 @@ fn process_command( for file in &files { q.add_track(file.clone()); } - if !audio.is_playing() + if was_empty + && audio.is_playing() && let Some(track) = q.current() { audio.play(track.path.clone()); @@ -519,8 +520,11 @@ fn process_command( } } } - // Use pager if output is long (more than 24 lines) - if output.lines().count() > 24 { + // Use pager if queue is longer than terminal height + let terminal_rows = terminal_size::terminal_size() + .map(|(w, _)| w.0 as usize) + .unwrap_or(24); + if output.lines().count() > terminal_rows { use std::process::{Command, Stdio}; let pager = Command::new("less").arg("-R").stdin(Stdio::piped()).spawn(); if let Ok(mut child) = pager { -- cgit v1.2.3