diff options
| -rw-r--r-- | .zed/tasks.json | 12 | ||||
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rwxr-xr-x | install.sh | 5 | ||||
| -rw-r--r-- | src/daemon.rs | 7 | ||||
| -rw-r--r-- | src/notification.rs | 16 |
6 files changed, 33 insertions, 11 deletions
diff --git a/.zed/tasks.json b/.zed/tasks.json index 40c9f3d..9bae85b 100644 --- a/.zed/tasks.json +++ b/.zed/tasks.json | |||
| @@ -3,12 +3,18 @@ | |||
| 3 | "label": "code coverage", | 3 | "label": "code coverage", |
| 4 | "command": "cargo tarpaulin", | 4 | "command": "cargo tarpaulin", |
| 5 | "show_command": false, | 5 | "show_command": false, |
| 6 | "show_summary": false | 6 | "show_summary": false, |
| 7 | }, | 7 | }, |
| 8 | { | 8 | { |
| 9 | "label": "run tests", | 9 | "label": "run tests", |
| 10 | "command": "cargo test", | 10 | "command": "cargo test", |
| 11 | "show_command": false, | 11 | "show_command": false, |
| 12 | "show_summary": false | 12 | "show_summary": false, |
| 13 | } | 13 | }, |
| 14 | { | ||
| 15 | "label": "install", | ||
| 16 | "command": "./install.sh", | ||
| 17 | "show_command": false, | ||
| 18 | "show_summary": false, | ||
| 19 | }, | ||
| 14 | ] | 20 | ] |
| @@ -1971,7 +1971,7 @@ dependencies = [ | |||
| 1971 | 1971 | ||
| 1972 | [[package]] | 1972 | [[package]] |
| 1973 | name = "rsp" | 1973 | name = "rsp" |
| 1974 | version = "0.1.0" | 1974 | version = "0.5.0" |
| 1975 | dependencies = [ | 1975 | dependencies = [ |
| 1976 | "chrono", | 1976 | "chrono", |
| 1977 | "clap", | 1977 | "clap", |
| @@ -1,6 +1,6 @@ | |||
| 1 | [package] | 1 | [package] |
| 2 | name = "rsp" | 2 | name = "rsp" |
| 3 | version = "0.1.0" | 3 | version = "0.5.0" |
| 4 | edition = "2024" | 4 | edition = "2024" |
| 5 | description = "Rust music player daemon with Unix socket IPC" | 5 | description = "Rust music player daemon with Unix socket IPC" |
| 6 | license = "GPL-3.0 or later" | 6 | license = "GPL-3.0 or later" |
| @@ -19,7 +19,8 @@ cp rsplayer.service ~/.config/systemd/user/ | |||
| 19 | 19 | ||
| 20 | if systemctl --user is-active default.target &>/dev/null; then | 20 | if systemctl --user is-active default.target &>/dev/null; then |
| 21 | systemctl --user daemon-reload | 21 | systemctl --user daemon-reload |
| 22 | echo "To enable auto-start: systemctl --user enable rsplayer" | 22 | echo "Activating the daemon…" |
| 23 | systemctl --user restart --now rsplayer.service | ||
| 23 | else | 24 | else |
| 24 | echo "Service installed but not enabled (no user session running)" | 25 | echo "Service installed but not enabled (no user session running)" |
| 25 | echo "To enable later when logged in: systemctl --user enable rsplayer" | 26 | echo "To enable later when logged in: systemctl --user enable rsplayer" |
| @@ -62,4 +63,4 @@ case "$shell_name" in | |||
| 62 | esac | 63 | esac |
| 63 | 64 | ||
| 64 | echo "" | 65 | echo "" |
| 65 | echo "Done! Run 'rsp start-daemon' to start the daemon." | 66 | echo "Done!" |
diff --git a/src/daemon.rs b/src/daemon.rs index acc7729..2b38025 100644 --- a/src/daemon.rs +++ b/src/daemon.rs | |||
| @@ -271,18 +271,22 @@ fn process_command( | |||
| 271 | } | 271 | } |
| 272 | "pause" => { | 272 | "pause" => { |
| 273 | audio.pause(); | 273 | audio.pause(); |
| 274 | notification::notify_change("Paused"); | ||
| 274 | "Paused\n".to_string() | 275 | "Paused\n".to_string() |
| 275 | } | 276 | } |
| 276 | "resume" => { | 277 | "resume" => { |
| 277 | audio.resume(); | 278 | audio.resume(); |
| 279 | notification::notify_change("Resumed"); | ||
| 278 | "Resumed\n".to_string() | 280 | "Resumed\n".to_string() |
| 279 | } | 281 | } |
| 280 | "toggle" => { | 282 | "toggle" => { |
| 281 | if audio.is_playing() { | 283 | if audio.is_playing() { |
| 282 | audio.pause(); | 284 | audio.pause(); |
| 285 | notification::notify_change("Paused"); | ||
| 283 | "Paused\n".to_string() | 286 | "Paused\n".to_string() |
| 284 | } else { | 287 | } else { |
| 285 | audio.resume(); | 288 | audio.resume(); |
| 289 | notification::notify_change("Resumed"); | ||
| 286 | "Resumed\n".to_string() | 290 | "Resumed\n".to_string() |
| 287 | } | 291 | } |
| 288 | } | 292 | } |
| @@ -291,6 +295,7 @@ fn process_command( | |||
| 291 | if let Ok(mut q) = queue.lock() { | 295 | if let Ok(mut q) = queue.lock() { |
| 292 | q.clear(); | 296 | q.clear(); |
| 293 | } | 297 | } |
| 298 | notification::notify_change("Stopped"); | ||
| 294 | "Stopped\n".to_string() | 299 | "Stopped\n".to_string() |
| 295 | } | 300 | } |
| 296 | "stop_daemon" => { | 301 | "stop_daemon" => { |
| @@ -551,6 +556,8 @@ fn process_command( | |||
| 551 | }; | 556 | }; |
| 552 | if track_idx == playing_track_idx && is_playing { | 557 | if track_idx == playing_track_idx && is_playing { |
| 553 | output.push_str(&format!("> {} (playing)\n", track_str)); | 558 | output.push_str(&format!("> {} (playing)\n", track_str)); |
| 559 | } else if track_idx == playing_track_idx && !is_playing { | ||
| 560 | output.push_str(&format!("> {} (paused)\n", track_str)); | ||
| 554 | } else { | 561 | } else { |
| 555 | output.push_str(&format!(" {}\n", track_str)); | 562 | output.push_str(&format!(" {}\n", track_str)); |
| 556 | } | 563 | } |
diff --git a/src/notification.rs b/src/notification.rs index 4947e6f..df9c622 100644 --- a/src/notification.rs +++ b/src/notification.rs | |||
| @@ -18,7 +18,7 @@ pub fn notify_track(track: &Track, format: Option<&str>) { | |||
| 18 | let _ = notify_rust::Notification::new() | 18 | let _ = notify_rust::Notification::new() |
| 19 | .summary("Now Playing") | 19 | .summary("Now Playing") |
| 20 | .body(&body) | 20 | .body(&body) |
| 21 | .appname("rsp") | 21 | .appname("RSPlayer") |
| 22 | .show(); | 22 | .show(); |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -26,14 +26,22 @@ pub fn notify_queue_ended() { | |||
| 26 | let _ = notify_rust::Notification::new() | 26 | let _ = notify_rust::Notification::new() |
| 27 | .summary("Playback Ended") | 27 | .summary("Playback Ended") |
| 28 | .body("The queue is empty") | 28 | .body("The queue is empty") |
| 29 | .appname("rsp") | 29 | .appname("RSPlayer") |
| 30 | .show(); | ||
| 31 | } | ||
| 32 | |||
| 33 | pub fn notify_change(state: &str) { | ||
| 34 | let _ = notify_rust::Notification::new() | ||
| 35 | .summary(state) | ||
| 36 | .body(&format!("Playback {}", state.to_lowercase())) | ||
| 37 | .appname("RSPlayer") | ||
| 30 | .show(); | 38 | .show(); |
| 31 | } | 39 | } |
| 32 | 40 | ||
| 33 | pub fn notify_error(context: &str) { | 41 | pub fn notify_error(context: &str) { |
| 34 | let _ = notify_rust::Notification::new() | 42 | let _ = notify_rust::Notification::new() |
| 35 | .summary("rsp Error") | 43 | .summary("RSPlayer Error") |
| 36 | .body(&format!("{} - Check the logs for details", context)) | 44 | .body(&format!("{} - Check the logs for details", context)) |
| 37 | .appname("rsp") | 45 | .appname("RSPlayer") |
| 38 | .show(); | 46 | .show(); |
| 39 | } | 47 | } |
