Last active
March 22, 2019 01:43
-
-
Save spotlightishere/0e12b7988d8cbb3b63a8b12962632210 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
rpc "github.com/dogboy21/go-discord-rp/connection" | |
"github.com/godbus/dbus" | |
"log" | |
"time" | |
) | |
func main() { | |
conn, err := dbus.SessionBus() | |
if err != nil { | |
panic(err) | |
} | |
log.Println("Connected.") | |
playerObject := conn.Object("org.mpris.MediaPlayer2.GnomeMusic", "/org/mpris/MediaPlayer2") | |
for { | |
metadataObject, err := playerObject.GetProperty("org.mpris.MediaPlayer2.Player.Metadata") | |
if err != nil { | |
log.Panicf("Failed to get metadata: %v", err) | |
} | |
log.Println("Got metadata.") | |
data := metadataObject.Value().(map[string]dbus.Variant) | |
title := data["xesam:title"].Value().(string) | |
album := data["xesam:album"].Value().(string) | |
artist := data["xesam:artist"].Value().([]string) | |
log.Println(title, "\n", album, " - ", artist[0]) | |
rpc.OpenSocket("402370117901484042") | |
rpc.SetActivityText(album + " - " + artist[0], title) | |
time.Sleep(30 * time.Second) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment