Skip to content

Instantly share code, notes, and snippets.

@orangecms
Created January 3, 2025 01:57
Show Gist options
  • Save orangecms/884cce21d2b1c01164c27420b6a4f5ea to your computer and use it in GitHub Desktop.
Save orangecms/884cce21d2b1c01164c27420b6a4f5ea to your computer and use it in GitHub Desktop.
stupid scripts because mpv is broken on RPi4 and cvlc is the way to go >_<
#!/bin/env python3
# convert time in microseconds to a human readable timestamp, e.g. 0:13:37.000123
from datetime import timedelta
import sys
ts=int(sys.argv[1])
td=timedelta(microseconds=ts)
print(str(td))
#!/bin/env bash
# seek 20s forward
dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:"20000000"
#!/bin/env bash
# seek 20s backward
dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Seek int64:"-20000000"
#!/bin/env bash
# get the current playback position, and let the Python script turn it into a human readable time format
ts=`dbus-send --dest=org.mpris.MediaPlayer2.vlc --print-reply /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:org.mpris.MediaPlayer2.Player string:Position | tail -n 1 | sed 's/.*int64 //'`
us2td $ts
#!/bin/env bash
# play/pause, the complicated way
dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment