Add .local/bin/sb-liisten
This commit is contained in:
parent
afd0dd5462
commit
17481dfeba
1 changed files with 38 additions and 0 deletions
38
.local/bin/sb-liisten
Normal file
38
.local/bin/sb-liisten
Normal file
|
@ -0,0 +1,38 @@
|
|||
#!/bin/sh
|
||||
#Liisten for the status bar
|
||||
|
||||
#options
|
||||
LOOPCOUNT=1 #however many times you want the song to play minus one (for technical reasons)
|
||||
SONGDIR="$HOME/music/brstm"
|
||||
cd "$SONGDIR"
|
||||
|
||||
MODE=$(printf "Random\nForever" | dmenu -i)
|
||||
|
||||
playsong () {
|
||||
vgmstream-cli -m "$SONG" > /tmp/brstminfo.txt
|
||||
STARTLOOP="$(grep "seconds" /tmp/brstminfo.txt | head -n 1 | sed 's/.*(//' | sed 's/ seconds)//')"
|
||||
ENDLOOP="$(grep "seconds" /tmp/brstminfo.txt | tail -n 1 | sed 's/.*(//' | sed 's/ seconds)//')"
|
||||
echo "Now playing: \"$(echo $SONG | sed 's/\.brstm//')\""
|
||||
mpv --ab-loop-a="$STARTLOOP" --ab-loop-b="$ENDLOOP" --ab-loop-count="$LOOPCOUNT" "$SONG"
|
||||
}
|
||||
|
||||
forever () {
|
||||
SONG="$(command ls -1 | dmenu -i)"
|
||||
vgmstream-cli -m "$SONG" > /tmp/brstminfo.txt
|
||||
STARTLOOP="$(grep "seconds" /tmp/brstminfo.txt | head -n 1 | sed 's/.*(//' | sed 's/ seconds)//')"
|
||||
ENDLOOP="$(grep "seconds" /tmp/brstminfo.txt | tail -n 1 | sed 's/.*(//' | sed 's/ seconds)//')"
|
||||
mpv --ab-loop-a="$STARTLOOP" --ab-loop-b="$ENDLOOP" --loop-file=inf "$SONG"
|
||||
}
|
||||
|
||||
random () {
|
||||
while true; do
|
||||
RANDNUM=$(shuf -i 1-$(ls -1 | wc -l) -n 1)
|
||||
SONG="$(command ls | head -n $RANDNUM | tail -n 1)"
|
||||
playsong
|
||||
done
|
||||
}
|
||||
|
||||
case "$MODE" in
|
||||
Forever) forever ;;
|
||||
Random) random ;;
|
||||
esac
|
Loading…
Add table
Reference in a new issue