|
|
@ -10,27 +10,28 @@ |
|
|
|
time_to_human(){ |
|
|
|
time_to_human(){ |
|
|
|
if [ "$API_OUTPUT" -gt 3600 ]; then |
|
|
|
if [ "$API_OUTPUT" -gt 3600 ]; then |
|
|
|
API_OUTPUT=$(printf '%d:%02d:%02d' $((API_OUTPUT/3600)) $((API_OUTPUT%3600/60)) $((API_OUTPUT%60))) |
|
|
|
API_OUTPUT=$(printf '%d:%02d:%02d' $((API_OUTPUT/3600)) $((API_OUTPUT%3600/60)) $((API_OUTPUT%60))) |
|
|
|
else |
|
|
|
elif [ "$API_OUTPUT" -gt 60 ]; then |
|
|
|
if [ "$API_OUTPUT" -gt 60 ]; then |
|
|
|
|
|
|
|
API_OUTPUT=$(printf '%02d:%02d' $((API_OUTPUT%3600/60)) $((API_OUTPUT%60))) |
|
|
|
API_OUTPUT=$(printf '%02d:%02d' $((API_OUTPUT%3600/60)) $((API_OUTPUT%60))) |
|
|
|
else |
|
|
|
else |
|
|
|
API_OUTPUT=$(printf '%02d' $((API_OUTPUT%60))) |
|
|
|
API_OUTPUT=$(printf '%02d' $((API_OUTPUT%60))) |
|
|
|
fi |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ! pgrep -u "$(id -u)" -x mpv > /dev/null; then |
|
|
|
|
|
|
|
exit 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
MPV_SOCKET_PATH="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/mpv/main.sock" |
|
|
|
MPV_SOCKET_PATH="${XDG_RUNTIME_DIR:-/tmp/$(id -u)-runtime}/mpv/main.sock" |
|
|
|
|
|
|
|
|
|
|
|
OUTPUT="" |
|
|
|
OUTPUT="" |
|
|
|
|
|
|
|
|
|
|
|
if pgrep -u "$(id -u)" -x mpv > /dev/null; then |
|
|
|
# The "16) Connection refused" error happens at the row below |
|
|
|
|
|
|
|
# See: https://github.com/deterenkelt/Nadeshiko/wiki/Known-issues-for-Nadeshiko%E2%80%91mpv#----connection-refused |
|
|
|
# The "16) Connection refused" error happens at the row below |
|
|
|
if ! TIME="$(printf '{ "command": ["get_property", "time-pos"] }\n' | socat - "$MPV_SOCKET_PATH" 2> /dev/null)"; then |
|
|
|
# See: https://github.com/deterenkelt/Nadeshiko/wiki/Known-issues-for-Nadeshiko%E2%80%91mpv#----connection-refused |
|
|
|
|
|
|
|
if ! TIME="$(printf '{ "command": ["get_property", "time-pos"] }\n' | socat - "$MPV_SOCKET_PATH" 2> /dev/null)"; then |
|
|
|
|
|
|
|
exit 1 |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
if [ "$(printf "%s" "$TIME" | jq -r .error)" = "success" ]; then |
|
|
|
|
|
|
|
|
|
|
|
if [ "$(printf "%s" "$TIME" | jq -r .error)" = "success" ]; then |
|
|
|
while [ $# -gt 0 ]; do |
|
|
|
while [ $# -gt 0 ]; do |
|
|
|
COMMAND=$1 |
|
|
|
COMMAND=$1 |
|
|
|
VALID_COMMAND=true |
|
|
|
VALID_COMMAND=true |
|
|
@ -79,12 +80,8 @@ if pgrep -u "$(id -u)" -x mpv > /dev/null; then |
|
|
|
OUTPUT="$OUTPUT$API_OUTPUT" |
|
|
|
OUTPUT="$OUTPUT$API_OUTPUT" |
|
|
|
shift; |
|
|
|
shift; |
|
|
|
done |
|
|
|
done |
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
OUTPUT="Loading..." |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
else |
|
|
|
else |
|
|
|
exit |
|
|
|
OUTPUT="Loading..." |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
printf %s "$OUTPUT" |
|
|
|
printf "%s" "$OUTPUT" |
|
|
|