Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use set_hint('image-path', ...) in notification #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/mpDris2.in.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,12 @@ def update_metadata(self):
(value, allowed_tags[key]))

def notify_about_track(self, meta, state='play'):
uri = 'sound'
uri = 'media-playback-start-symbolic'
artUrl = ''
if 'mpris:artUrl' in meta:
uri = meta['mpris:artUrl']
artUrl = meta['mpris:artUrl']
else:
pass

title = 'Unknown Title'
if 'xesam:title' in meta:
Expand All @@ -602,9 +605,8 @@ def notify_about_track(self, meta, state='play'):

if state == 'pause':
uri = 'media-playback-pause-symbolic'
body += ' (%s)' % _('Paused')

notification.notify(title, body, uri)
notification.notify(title, body, uri, artUrl)

def notify_about_state(self, state):
if state == 'stop':
Expand Down Expand Up @@ -939,22 +941,24 @@ def _bootstrap_notifications(self):

return notif

def notify(self, title, body, uri=''):
def notify(self, title, body, uri='', artUrl=''):
if not self._enabled:
return

# If we did not yet manage to get a notification service,
# try again
if not self._notification:
logger.info('Retrying to acquire a notification service provider...')
self._notification = self._bootstrap_notifications()
if self._notification:
logger.info('Notification service provider acquired!')

if self._notification:
try:
self._notification.close()
self._notification.set_urgency(params['notify_urgency'])
self._notification.update(title, body, uri)
self._notification.set_hint('image-path', GLib.Variant("s", artUrl))
self._notification.show()
except GLib.GError as err:
logger.error("Failed to show notification: %s" % err)
Expand Down