-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmuxsic.sh
executable file
·66 lines (62 loc) · 1.51 KB
/
muxsic.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/data/data/com.termux/files/usr/bin/bash
# MuxSic [ Termux Music ]
# Version: 1.0-beta
# Author: Bagaz Mukti
# Github: github.com/BagazMukti/
# Website: bagaz.org
# Contact: me@bl33dz.me
export DIR="$HOME/Music"
echo -e " _ _ _ _ _ _ ____ __ ___
( \/ )/ )( \( \/ )___ / ___)( )/ __)
/ \/ \) \/ ( ) ((___)\___ \ )(( (__
\_)(_/\____/(_/\_) (____/(__)\___)
[ Termux Music ~ v1.0-beta ]\n"
loop=true
while $loop; do
trap '' 2
read -p "muxsic> " cmd
if [ "$cmd" = "help" ]; then
echo -e "List of commands:
> list show playlist
> play <number> play music
> play all play all music on playlist
> chdir <path> change playlist directory (current: $DIR)
> help show this help
> exit exit from this program\n"
elif [ "$cmd" = "list" ]; then
getlist=$(ls $DIR | grep mp3)
replace=${getlist// /%%}
n=1
for music in $replace; do
echo "[$n] ${music//%%/ }"
((n++))
done
echo
elif echo "$cmd" | grep -q "play"; then
arg=$(echo "$cmd" | cut -d " " -f 2)
getlist=$(ls $DIR | grep mp3)
replace=${getlist// /%%}
list=()
for m in $replace; do
list+=("$m")
done
if [ $arg = "all" ]; then
for ms in $replace; do
trap 'break' 2
mpv "$DIR/${ms//%%/ }"
done
else
music=${list[(($arg-1))]}
mpv "$DIR/${music//%%/ }"
fi
echo
elif echo "$cmd" | grep -q "chdir"; then
export DIR="$(echo "$cmd" | cut -d " " -f 2)"
echo "Directory changed!"
echo
elif [ "$cmd" = "exit" ]; then
loop=false
else
echo "W000t?? please type \"help\""
fi
done