From f9ef805e513918115334746e11dadf7be9b921a0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 18 Jul 2022 12:06:10 -0500 Subject: Add -r command line option: Resume last played station --- radio | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/radio b/radio index 8209ac7..d94d585 100755 --- a/radio +++ b/radio @@ -31,6 +31,7 @@ FLAGS: -h Show this help. -k Kill the currently-playing radio invocation. -K Kill all instances of $RADIO_PLAYER. + -r Begin playing most recently-played radio, or prompt user. -e Edit \$RADIO_STATIONS using \$EDITOR. -s Show radio's status and exit. -S Show radio's status until the user quits with C-c. @@ -44,7 +45,7 @@ EOF } main() { - while getopts :kKsShel: opt; do + while getopts :kKrsShel: opt; do case $opt in h) usage ;; k) _radio_kill ;; @@ -52,6 +53,7 @@ main() { pkill "$RADIO_PLAYER" exit ;; + r) set -- "$(cat /tmp/radio.last_played)" ;; e) _radio_edit ;; s) _radio_status ;; S) _radio_status -f ;; @@ -103,6 +105,8 @@ _radio_play() { station="$candidates" fi + echo "$station" | cut -f $_radio_desc >/tmp/radio.last_played + if [ -f "$RADIO_PID_FILE" ]; then _radio_kill_impl fi -- cgit 1.4.1-21-gabe81