Skip to content

Instantly share code, notes, and snippets.

@luisadha
Last active October 1, 2024 15:27
Show Gist options
  • Save luisadha/c2deebfe23b622dfcaa82aa0a8909034 to your computer and use it in GitHub Desktop.
Save luisadha/c2deebfe23b622dfcaa82aa0a8909034 to your computer and use it in GitHub Desktop.
#!/data/data/com.termux/files/usr/bin/bash
# Created @luisadha
set +o noclobber;
format='audio/mp3';
format2='audio';
file="${1:+"${1}/*.mp3"}";
file2="${1:-"${HOME}/downloads/*.mp3"}";
files=$(busybox ls ${file:-${file2}});
n="${#files[@]}";
pick="${files[RANDOM % n]}";
result="$(printf "${0:+${pick}}" | shuf -n 1)";
tmp="/sdcard/Download/"$(basename "${result}")"";
\cd "/sdcard/Download" &> /dev/null;
\cp -rf "${result}" "${tmp}" &> /dev/null;
echo "Apakah Anda ingin melanjutkan? (y/n)"
read -n 1 answer # Membaca satu karakter sebagai input
if [[ "$answer" =~ ^[Yy]$ ]]; then
echo "Anda memilih untuk melanjutkan."
eval `am start -a android.intent.action.VIEW -d file://"${tmp}" -t ${format} ` &> /dev/null; sleep 1;
echo;
cd - &> /dev/null;
else
echo "Anda memilih untuk berhenti."
rm -f "${tmp}";
termux-toast "timeout or done!";
cd - &> /dev/null;
fi
#!/usr/bin/expect
spawn brandomusic2
expect {
"(y/n)" {
send "y\r"
}
}
expect eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment