mirror of https://github.com/CIRCL/Circlean
Refactor music.sh to use functions
parent
66f2dd25f2
commit
fce66420c8
|
@ -1,22 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
|
||||||
#set -x
|
|
||||||
|
|
||||||
source ./config.sh
|
|
||||||
|
|
||||||
killed(){
|
killed(){
|
||||||
echo 'Music stopped.'
|
echo 'Music stopped.'
|
||||||
}
|
}
|
||||||
|
|
||||||
trap killed EXIT TERM INT
|
run_timidity() {
|
||||||
|
# Force output on analog
|
||||||
# Force output on analog
|
amixer cset numid=3 1
|
||||||
amixer cset numid=3 1
|
files=(${MUSIC_DIR}*)
|
||||||
|
while true; do
|
||||||
files=(${MUSIC_DIR}*)
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
# -id flags set interface to "dumb" and -qq silences most/all terminal output
|
# -id flags set interface to "dumb" and -qq silences most/all terminal output
|
||||||
$TIMIDITY -idqq ${files[RANDOM % ${#files[@]}]}
|
"${TIMIDITY}" -idqq "${files[RANDOM % ${#files[@]}]}"
|
||||||
done
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
set -eu # exit when a line returns non-0 status, treat unset variables as errors
|
||||||
|
trap killed EXIT TERM INT # run clean when the script ends or is interrupted
|
||||||
|
check_is_root
|
||||||
|
source ./config.sh # get config values
|
||||||
|
run_timidity
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
|
Loading…
Reference in New Issue