-
-
Save coolreader18/17faf265b849f2e14fa6eef83b826441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
INFO_LINES=4 | |
dir=. | |
while getopts "d:" opt; do | |
case "$opt" in | |
d) | |
dir=$OPTARG | |
;; | |
esac | |
done | |
cd "$dir" 2>/dev/null || { | |
>&2 echo "Provided dir option '$dir' is not a valid directory." | |
exit 1 | |
} | |
HOME=$(tput home; tput rmso) | |
SC=$(tput sc) | |
RC=$(tput rc) | |
CLEARTOP=$( | |
tput rmso | |
for i in 0..$INFO_LINES; do | |
tput cup $i 0 | |
tput el | |
done | |
) | |
CLEARREST=$(tput ed) | |
CLEARLINE=$(tput el) | |
tput smcup | |
tput clear | |
cleanup() { | |
pkill -P $$ | |
tput rmcup | |
exit 0 | |
} | |
trap cleanup SIGINT EXIT | |
while true; do | |
output=$(termux-media-player info) | |
echo -n "$SC$CLEARTOP$HOME$output$RC" | |
done & | |
INPUT=$(tput cup $INFO_LINES 0; tput smso) | |
OUTPUT=$(tput cup $((INFO_LINES+1)) 0; tput rmso) | |
echo -n "$INPUT$CLEARLINE" | |
while true; do | |
read -a cmd | |
case "${cmd[0]}" in | |
vol) output=$(termux-volume music "${cmd[1]}") ;; | |
q|quit) exit 0 ;; | |
*) output=$(termux-media-player ${cmd[@]}) ;; | |
esac | |
echo -n "$OUTPUT$CLEARREST$output$INPUT$CLEARLINE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment