blechelse.sh/inc/zuege.sh
2025-04-01 21:01:31 +02:00

46 lines
1.5 KiB
Bash
Executable file

Zuggattung() {
#ICE, RE usw.
printf "${RED}$Zuggattung${NC}\n"
mpv modules/dt/zuggattungen/hoch//$Zuggattung.wav 2&>1 1>/dev/null
}
ZugNr() {
# Check if the input is a valid number
if ! [[ "$ZugNr" =~ ^[0-9]+$ ]]; then
echo "Please enter a valid number."
exit 1
fi
# Get the length of the number
length=${#ZugNr}
# Check if the number has at least 3 digits
if [[ $length -eq 1 ]]; then
mpv modules/dt/gleise_zahlen//hoch/$ZugNr.wav 2&>1 1>/dev/null
printf "${RED}$ZugNr${NC}\n"
elif [[ $length -eq 2 ]]; then
printf "${RED}$ZugNr${NC}\n"
mpv modules/dt/gleise_zahlen//hoch/$ZugNr.wav 2&>1 1>/dev/null
elif [[ $length -eq 3 ]]; then
# Get the first part by truncating to the nearest hundred
first_part=$(($ZugNr / 100 * 100)) # Truncate to the nearest hundred
second_part=$(($ZugNr % 100)) # Get the remainder (last two digits)
printf "${RED}$first_part${NC}\n"
mpv modules/dt/gleise_zahlen//hoch/${first_part}_.wav 2&>1 1>/dev/null
printf "${RED}$second_part${NC}\n"
mpv modules/dt/gleise_zahlen/hoch//$second_part.wav 2&>1 1>/dev/null
elif [[ $length -eq 4 ]]; then
# Split a 4-digit number into 2 + 2
first_part="${ZugNr:0:2}" # First two digits
second_part="${ZugNr:2:2}" # Last two digits
printf "${RED}$first_part${NC}\n"
mpv modules/dt/gleise_zahlen//hoch/${first_part}.wav 2&>1 1>/dev/null
printf "${RED}$second_part${NC}\n"
mpv modules/dt/gleise_zahlen/hoch//$second_part.wav 2&>1 1>/dev/null
else
echo "Please enter a number with at least 3 digits."
fi
}