Skip to content

Instantly share code, notes, and snippets.

@exic
exic / mediaplayer2-listening
Created December 2, 2014 12:11
Get status from player implementing MPRIS D-Bus Specification v2.2
#!/usr/bin/env python
import sys
from os import environ
if 'DISPLAY' not in environ:
exit(0)
name = "rhythmbox"
if len(sys.argv) > 1:
@exic
exic / player-control
Created December 2, 2014 12:16
Control a player implementing MPRIS D-Bus Specification v2.2
#!/bin/sh
name="$1"
shift
PATHS="org.mpris.MediaPlayer2.$name /org/mpris/MediaPlayer2"
DBUS_SEND="dbus-send --type=method_call --dest=$PATHS"
RC="$DBUS_SEND org.mpris.MediaPlayer2.Player"
if [ "$@" = "prev" ]; then
$RC.Previous
elif [ "$@" = "stop" ]; then
$RC.Pause