From 284c12f781bd0c0b2e8f69c54983463fa911e858 Mon Sep 17 00:00:00 2001 From: Marty Oehme <marty.oehme@gmail.com> Date: Thu, 23 Jan 2025 16:49:40 +0100 Subject: [PATCH] vidl: Allow getting current status Can now get the current status with -p option (either running or stopped) and currently remaining queue items with -P option. --- scripts/.local/bin/vidl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/scripts/.local/bin/vidl b/scripts/.local/bin/vidl index 5192922..86b34bf 100755 --- a/scripts/.local/bin/vidl +++ b/scripts/.local/bin/vidl @@ -33,7 +33,7 @@ Options: urls=("$@") -while getopts "t:f:d:hcp" opt; do +while getopts "t:f:d:hcpP" opt; do case "$opt" in # v) verbose=1 # ;; @@ -50,6 +50,9 @@ while getopts "t:f:d:hcp" opt; do ONLY_DO=clear ;; p) + ONLY_DO=status + ;; + P) ONLY_DO=remaining ;; h | \? | *) @@ -155,6 +158,7 @@ is_in_queue() { # 1=url } add_to_queue() { # 1=url + if is_in_queue "$1"; then return; fi echo "$1" >>"$queue_file" echo "added $url to queue." @@ -193,6 +197,14 @@ print_queue_remaining() { wc -l "$queue_file" | cut -f1 -d' ' } +print_status() { + if is_only_instance; then + printf "stopped\n" + return + fi + printf "running\n" +} + main() { setup if [ "$ONLY_DO" = "clear" ]; then @@ -201,6 +213,9 @@ main() { elif [ "$ONLY_DO" = "remaining" ]; then print_queue_remaining exit + elif [ "$ONLY_DO" = "status" ]; then + print_status + exit fi for url in "$@"; do