Skip to content

Loading…

Added in Telepathy Integration #6

Merged
merged 6 commits into from

3 participants

@dhananjaysathe

Now Playing support for telepathy based clients such as Empathy , KDE Telepatthy and Pidgin now baked into spotify-gnome.
Displays now playing in telepathy clients as the presence status.

@jreese jreese merged commit 6b988bc into jreese:master
@jreese
Owner

Thank you :)

@dhananjaysathe
@sebastianst

Updated my Arch Linux AUR package to include the optional depency for telepathy-glib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 18, 2013
  1. @dhananjaysathe
  2. @dhananjaysathe
  3. @dhananjaysathe

    PEP-8 Cleanups

    dhananjaysathe committed
Commits on Jan 19, 2013
  1. @dhananjaysathe
  2. @dhananjaysathe

    Update readme and License

    dhananjaysathe committed
  3. @dhananjaysathe

    README.md fixup

    dhananjaysathe committed
Showing with 37 additions and 0 deletions.
  1. +1 −0 LICENSE
  2. +4 −0 README.md
  3. +32 −0 bin/spotify
View
1 LICENSE
@@ -1,4 +1,5 @@
Copyright (C) 2011 John Reese
+Copyright (C) 2013 Dhananjay Sathe dhananjaysathe@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
4 README.md
@@ -12,6 +12,9 @@ to translate media key signals from Gnome and send them to the Spotify client.
It supports the play/pause, stop, next, and previous signals, and is compatible with
both Gnome 2 and Gnome 3.
+NEW Jan 2013 - Get Now Playing integration for telepathy based clients such as
+Empathy,Pidgin,Kde Telepathy Sugar using lib telepahty support from gobject-introspection - dhananjaysathe@gmail.com
+
Many thanks to [Mike Houston at kothar.net](http://kothar.net/index.php/blog/30-spotifydbus)
and [Fran Diéguez at Mabishu](http://www.mabishu.com/blog/2010/11/15/playing-with-d-bus-interface-of-spotify-for-linux/)
for their blog postings that pointed me in the right directions to get this implemented.
@@ -42,6 +45,7 @@ Support
-------
Spotify-Gnome was created by [John Reese](http://johnmreese.com), and copyright (c) 2011.
+Telepathy support - [Dhananjay Sathe](http://dsathe.blogspot.com)
Spotify-Gnome is licensed under the MIT license. See the LICENSE files for details.
Bugs can be reported on [my bug tracker](http://leetcode.net/mantis/).
View
32 bin/spotify
@@ -1,4 +1,5 @@
#!/usr/bin/env python2
+# coding: utf-8
import dbus
import dbus.service
@@ -15,6 +16,13 @@ except:
print "Disabling notifications"
import gobject
ENABLE_NOTIFICATIONS = False
+try:
+ from gi.repository import TelepathyGLib as telepathy
+ ENABLE_TELEPATHY = True
+except:
+ print "Disabling telepathy support"
+ import gobject
+ ENABLE_TELEPATHY = False
spotify_bin = "/usr/bin/spotify"
@@ -55,7 +63,9 @@ class SpotifyGnome(object):
"org.gnome.SettingsDaemon.MediaKeys")
self.loop = gobject.MainLoop()
+ self.telepathy_loop = gobject.MainLoop()
self.loop.run()
+ self.telepathy_loop.run()
print "Done"
@@ -74,12 +84,15 @@ class SpotifyGnome(object):
if ENABLE_NOTIFICATIONS:
self.initialize_notifications()
+ if ENABLE_TELEPATHY:
+ self.initialize_telepathy()
else:
self.mediakeys.ReleaseMediaPlayerKeys("Spotify")
if ENABLE_NOTIFICATIONS:
self.notification.close()
Notify.uninit()
self.loop.quit()
+ self.telepathy_loop.quit()
def key_pressed(self, *keys):
print "Received MediaPlayerKeyPressed:"
@@ -102,6 +115,13 @@ class SpotifyGnome(object):
elif key == "Previous":
self.spotify.Previous()
+ def initialize_telepathy(self):
+ print "Connecting to Telepathy..."
+ self.telepathy_accn_manager = telepathy.AccountManager.dup()
+ self.telepathy_accn_manager.prepare_async(None, lambda *args: self.telepathy_loop.quit(), None)
+ self.telepathy_away = True
+
+
def initialize_notifications(self):
self.current_song = {}
@@ -131,19 +151,31 @@ class SpotifyGnome(object):
title = self.current_song['title']
body = "{0}\n{1} ({2})".format(self.current_song['artist'], self.current_song['album'], self.current_song['year'])
icon = "media-playback-start"
+ status_content = 'Spotify : '+self.current_song["title"]+' - '+self.current_song["artist"]
+ self.telepathy_away = False
if 'PlaybackStatus' in changed_properties:
if changed_properties['PlaybackStatus'] == 'Paused':
title = "Paused"
body = None
icon = "media-playback-pause"
+ status_content = 'Spotify : Paused'
+ self.telepathy_away = True
if changed_properties['PlaybackStatus'] == 'Stopped':
title = "Stopped"
body = None
icon = "media-playback-stop"
+ status_content = 'Spotify : Stopped'
+ self.telepathy_away = True
self.notification.update(title, body, icon)
self.notification.show()
+ status = "".decode('utf8')+status_content+"".decode('utf8')
+ if ENABLE_TELEPATHY:
+ if self.telepathy_away :
+ self.telepathy_accn_manager.set_all_requested_presences(telepathy.ConnectionPresenceType.AWAY,'away', status)
+ else:
+ self.telepathy_accn_manager.set_all_requested_presences(telepathy.ConnectionPresenceType.AVAILABLE,'available', status)
if __name__ == "__main__":
SpotifyGnome()
Something went wrong with that request. Please try again.