mirror of
https://tilde.club/~comet/git/musefetch.git
synced 2026-01-23 23:40:18 +00:00
Print Track Details
Get and Print current player data from DBus
This commit is contained in:
@@ -1,5 +1,32 @@
|
||||
import dbus
|
||||
import json
|
||||
|
||||
|
||||
def get_players():
|
||||
players = []
|
||||
|
||||
for name in dbus.SessionBus().list_names():
|
||||
if name.startswith("org.mpris.MediaPlayer2."):
|
||||
players.append(name)
|
||||
|
||||
return players
|
||||
|
||||
|
||||
def main():
|
||||
print("Hello World :)")
|
||||
player = dbus.Interface(
|
||||
dbus.SessionBus().get_object(get_players()[0], "/org/mpris/MediaPlayer2"),
|
||||
"org.freedesktop.DBus.Properties",
|
||||
)
|
||||
|
||||
playing = (
|
||||
True
|
||||
if player.Get("org.mpris.MediaPlayer2.Player", "PlaybackStatus") == "Playing"
|
||||
else False
|
||||
)
|
||||
metadata = player.Get("org.mpris.MediaPlayer2.Player", "Metadata")
|
||||
|
||||
print(f"Playing: {playing}")
|
||||
print(json.dumps(metadata, indent=4))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user