Bash 스크립트에 여러 비디오를 대기열에 추가

Bash 스크립트에 여러 비디오를 대기열에 추가

- 보풀을 건너뛰려면 굵은 글씨로 건너뛰세요 -

저는 우분투를 처음 접했기 때문에 여전히 bash 스크립트 작동 방식을 배우고 있습니다. 제가 작업해온 이 코드가 있는데 아주 잘 작동합니다. (부가 질문 - 카운트다운 섹션을 최적화할 수 있습니까? 한 번 정의한 다음 모든 섹션에서 호출합니까?) 해당 totem "/video/location/here.ext"명령을 사용할 때 내 문제는 비디오 플레이어가 하나의 비디오만 로드한다는 것입니다.

실제적인 문제totem "/video.ext": 터미널에서 명령을 사용할 때 Totem이 현재 비디오가 끝난 후 다음 비디오를 자동으로 계속하도록 하려면 어떻게 해야 합니까?

#!/bin/bash

PS3='
So, you want to watch Elfen Lied? Choose an episode (1-14): '
options=("A Chance Encounter" "Annihilation" "Deep Feelings" "Attack" "Receipt" "Innermost Feelings" "Confrontation" "The Beginning" "Reminiscence" "Infant" "Complication" "Quagmire" "No Return" "Episode 10.5 - OVA" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "A Chance Encounter")
            echo "You chose Episode 01 - A Chance Encounter"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 01 - A Chance Encounter.mkv";;
        "Annihilation")
            echo "You chose Episode 02 - Annihilation"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 02 - Annihilation.mkv";;
        "Deep Feelings")
            echo "You chose Episode 03 - Deep Feelings"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 03 - Deep Feelings.mkv";;
        "Attack")
            echo "You chose Episode 04 - Attack"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 04 - Attack.mkv";;
        "Receipt")
            echo "You chose Episode 05 - Receipt"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 05 - Receipt.mkv";;
        "Innermost Feelings")
            echo "You chose Episode 06 - Innermost Feelings"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 06 - Innermost Feelings.mkv";;
        "Confrontation")
            echo "You chose Episode 07 - Confrontation"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 07 - Confrontation.mkv";;
        "The Beginning")
            echo "You chose Episode 08 - The Beginning"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 08 - The Beginning.mkv";;
        "Reminiscence")
            echo "You chose Episode 09 - Reminiscence"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 09 - Reminiscence.mkv";;
        "Infant")
            echo "You chose Episode 10 - Infant"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 10 - Infant.mkv";;
        "Complication")
            echo "You chose Episode 11 - Complication"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 11 - Complication.mkv";;
        "Quagmire")
            echo "You chose Episode 12 - Quagmire"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 12 - Quagmire.mkv";;
        "No Return")
            echo "You chose Episode 13 - No Return"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 13 - No Return.mkv";;
        "Episode 10.5 - OVA")
            echo "You chose Episode 10.5 - OVA"
            sleep 1
            echo "Starting in 3..."
            sleep 1
            echo "Starting in 2..."
            sleep 1
            echo "Starting in 1..."
            sleep 1
            totem "/home/xhynk/Desktop/media/Anime/Elfen Lied/Elfen Lied - 14 (10.5 OVA).mkv";;
        "Quit")
            break;;
        *) echo "Invalid Option. Type 1-14, or type 15 to quit.";;
    esac
done

답변1

#!/usr/bin/env bash

countdown() {
  i=$1
  while [ $i -gt 0 ]; do
    printf "Starting in %d...\n" $i
    sleep 1
    i=$(( i - 1 ))
  done
}

countdown 3

이제 좀 더 화려해지고 싶다면 tput다음을 살펴보는 것이 좋습니다.

tcountdown() {
  i=$1
  clear
  while [ $i -gt 0 ]; do
    tput cup $(( i - 1 )) 40
    printf $i
    sleep 1
    i=$(( i - 1 ))
  done
  tput cup 0 40
  printf "0\n"
}

관련 정보