diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-09 15:14:33 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-09 15:14:33 +0200 |
| commit | b3b7f0f65295f2100eb3c9880e870349c43701a6 (patch) | |
| tree | 1b24e6eecc8d7fbe3720208fb496604fe430ab45 /src/daemon.rs | |
| parent | Add TODO for major rewrite phases (diff) | |
| download | rsplayer-b3b7f0f65295f2100eb3c9880e870349c43701a6.tar.gz rsplayer-b3b7f0f65295f2100eb3c9880e870349c43701a6.zip | |
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
Diffstat (limited to '')
| -rw-r--r-- | src/daemon.rs | 14 |
1 files changed, 9 insertions, 5 deletions
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( | |||
| 399 | format!("Queued next: {}\n", path_str) | 399 | format!("Queued next: {}\n", path_str) |
| 400 | } | 400 | } |
| 401 | _ => { | 401 | _ => { |
| 402 | let was_playing = audio.is_playing(); | 402 | let was_empty = q.is_empty(); |
| 403 | q.add_track(path.clone()); | 403 | q.add_track(path.clone()); |
| 404 | if !was_playing { | 404 | if was_empty && audio.is_playing() { |
| 405 | let track = Track::from_path(path.clone()); | 405 | let track = Track::from_path(path.clone()); |
| 406 | audio.play(path); | 406 | audio.play(path); |
| 407 | notification::notify_track(&track); | 407 | notification::notify_track(&track); |
| @@ -452,7 +452,8 @@ fn process_command( | |||
| 452 | for file in &files { | 452 | for file in &files { |
| 453 | q.add_track(file.clone()); | 453 | q.add_track(file.clone()); |
| 454 | } | 454 | } |
| 455 | if !audio.is_playing() | 455 | if was_empty |
| 456 | && audio.is_playing() | ||
| 456 | && let Some(track) = q.current() | 457 | && let Some(track) = q.current() |
| 457 | { | 458 | { |
| 458 | audio.play(track.path.clone()); | 459 | audio.play(track.path.clone()); |
| @@ -519,8 +520,11 @@ fn process_command( | |||
| 519 | } | 520 | } |
| 520 | } | 521 | } |
| 521 | } | 522 | } |
| 522 | // Use pager if output is long (more than 24 lines) | 523 | // Use pager if queue is longer than terminal height |
| 523 | if output.lines().count() > 24 { | 524 | let terminal_rows = terminal_size::terminal_size() |
| 525 | .map(|(w, _)| w.0 as usize) | ||
| 526 | .unwrap_or(24); | ||
| 527 | if output.lines().count() > terminal_rows { | ||
| 524 | use std::process::{Command, Stdio}; | 528 | use std::process::{Command, Stdio}; |
| 525 | let pager = Command::new("less").arg("-R").stdin(Stdio::piped()).spawn(); | 529 | let pager = Command::new("less").arg("-R").stdin(Stdio::piped()).spawn(); |
| 526 | if let Ok(mut child) = pager { | 530 | if let Ok(mut child) = pager { |
