|
|
|
@ -10,27 +10,28 @@ |
|
|
|
|
time_to_human(){ |
|
|
|
|
if [ "$API_OUTPUT" -gt 3600 ]; then |
|
|
|
|
API_OUTPUT=$(printf '%d:%02d:%02d' $((API_OUTPUT/3600)) $((API_OUTPUT%3600/60)) $((API_OUTPUT%60))) |
|
|
|
|
else |
|
|
|
|
if [ "$API_OUTPUT" -gt 60 ]; then |
|
|
|
|
elif [ "$API_OUTPUT" -gt 60 ]; then |
|
|
|
|
API_OUTPUT=$(printf '%02d:%02d' $((API_OUTPUT%3600/60)) $((API_OUTPUT%60))) |
|
|
|
|
else |
|
|
|
|
API_OUTPUT=$(printf '%02d' $((API_OUTPUT%60))) |
|
|
|
|
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" |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
if ! TIME="$(printf '{ "command": ["get_property", "time-pos"] }\n' | socat - "$MPV_SOCKET_PATH" 2> /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 |
|
|
|
|
if ! TIME="$(printf '{ "command": ["get_property", "time-pos"] }\n' | socat - "$MPV_SOCKET_PATH" 2> /dev/null)"; then |
|
|
|
|
exit 1 |
|
|
|
|
fi |
|
|
|
|
if [ "$(printf "%s" "$TIME" | jq -r .error)" = "success" ]; then |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
if [ "$(printf "%s" "$TIME" | jq -r .error)" = "success" ]; then |
|
|
|
|
while [ $# -gt 0 ]; do |
|
|
|
|
COMMAND=$1 |
|
|
|
|
VALID_COMMAND=true |
|
|
|
@ -79,12 +80,8 @@ if pgrep -u "$(id -u)" -x mpv > /dev/null; then |
|
|
|
|
OUTPUT="$OUTPUT$API_OUTPUT" |
|
|
|
|
shift; |
|
|
|
|
done |
|
|
|
|
|
|
|
|
|
else |
|
|
|
|
OUTPUT="Loading..." |
|
|
|
|
fi |
|
|
|
|
else |
|
|
|
|
exit |
|
|
|
|
OUTPUT="Loading..." |
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
printf %s "$OUTPUT" |
|
|
|
|
printf "%s" "$OUTPUT" |
|
|
|
|