Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6817681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:05:07+00:00 2026-05-26T21:05:07+00:00

I’m getting error when I try setting status to empathy with dbus using python,

  • 0

I’m getting error when I try setting status to empathy with dbus using python,
this is the code I’ve got from different sources

## getting status from clementine music player

import dbus

# Clementine lives on the Session bus
session_bus = dbus.SessionBus()

# Get Clementine's player object, and then get an interface from that object,
# otherwise we'd have to type out the full interface name on every method call.
player = session_bus.get_object('org.mpris.clementine', '/Player')
iface = dbus.Interface(player, dbus_interface='org.freedesktop.MediaPlayer')

# Call a method on the interface
metadata = iface.GetMetadata()
print metadata["title"]+' - '+metadata["artist"]
status = metadata["title"]+' - '+metadata["artist"]

## the below code is from https://github.com/engla/kupfer/blob/master/kupfer/plugin/empathy.py
import os
import subprocess
import sys
import time

import pynotify as pn

# it takes a long time before empathy is willing to accept statuses
EMPATHY_STARTUP_SECONDS = 20

def show_usage():
    print "\nUsage:"
    print sys.argv[0], "|".join(_STATUSES.keys())

def set_status(status):
    try:

        activate(status)
        notify_set_status(status)
    except IndexError:
        print "Missing required parameter."
        show_usage()
    except ValueError as err:
        print err
        show_usage()

def notify_set_status(status):
    success = pn.init("icon-summary-body")
    if not success:
        raise Error()

    # I like this icon, even if it's not relevant
    icon = 'notification-keyboard-brightness-low'
    pn.Notification("Empathy", "Tried to set status to "+ status, icon).show()

def main():# give empathy some time to start up
    set_status(status)


def _(text):
    return text

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# All code below was derived from https://github.com/engla/kupfer/blob/master/kupfer/plugin/empathy.py
ACCOUNTMANAGER_PATH = "/org/freedesktop/Telepathy/AccountManager"
ACCOUNTMANAGER_IFACE = "org.freedesktop.Telepathy.AccountManager"
ACCOUNT_IFACE = "org.freedesktop.Telepathy.Account"
CHANNEL_GROUP_IFACE = "org.freedesktop.Telepathy.Channel.Interface.Group"
CONTACT_IFACE = "org.freedesktop.Telepathy.Connection.Interface.Contacts"
SIMPLE_PRESENCE_IFACE = "org.freedesktop.Telepathy.Connection.Interface.SimplePresence"
DBUS_PROPS_IFACE = "org.freedesktop.DBus.Properties"
CHANNELDISPATCHER_IFACE = "org.freedesktop.Telepathy.ChannelDispatcher"
CHANNELDISPATCHER_PATH = "/org/freedesktop/Telepathy/ChannelDispatcher"
CHANNEL_TYPE = "org.freedesktop.Telepathy.Channel.ChannelType"
CHANNEL_TYPE_TEXT = "org.freedesktop.Telepathy.Channel.Type.Text"
CHANNEL_TARGETHANDLE = "org.freedesktop.Telepathy.Channel.TargetHandle"
CHANNEL_TARGETHANDLETYPE = "org.freedesktop.Telepathy.Channel.TargetHandleType"
EMPATHY_CLIENT_IFACE = "org.freedesktop.Telepathy.Client.Empathy"

EMPATHY_ACCOUNT_KEY = "EMPATHY_ACCOUNT"
EMPATHY_CONTACT_ID = "EMPATHY_CONTACT_ID"


_ATTRIBUTES = {
    'alias': 'org.freedesktop.Telepathy.Connection.Interface.Aliasing/alias',
    'presence': 'org.freedesktop.Telepathy.Connection.Interface.SimplePresence/presence',
    'contact_caps': 'org.freedesktop.Telepathy.Connection.Interface.ContactCapabilities.DRAFT/caps',
    'jid': 'org.freedesktop.Telepathy.Connection/contact-id',
    'caps': 'org.freedesktop.Telepathy.Connection.Interface.Capabilities/caps',
}
def _create_dbus_connection():
        sbus = dbus.SessionBus()
        proxy_obj = sbus.get_object(ACCOUNTMANAGER_IFACE, ACCOUNTMANAGER_PATH)
        dbus_iface = dbus.Interface(proxy_obj, DBUS_PROPS_IFACE)
        return dbus_iface

def activate(status):

    bus = dbus.SessionBus()
    interface = _create_dbus_connection()
    for valid_account in interface.Get(ACCOUNTMANAGER_IFACE, "ValidAccounts"):
        account = bus.get_object(ACCOUNTMANAGER_IFACE, valid_account)
        connection_status = account.Get(ACCOUNT_IFACE, "ConnectionStatus")
        if connection_status != 0:
            continue

        connection_path = account.Get(ACCOUNT_IFACE, "Connection")
        connection_iface = connection_path.replace("/", ".")[1:]
        connection = bus.get_object(connection_iface, connection_path)
        simple_presence = dbus.Interface(connection, SIMPLE_PRESENCE_IFACE)
        try:
            simple_presence.SetPresence(status, _(status))
        except dbus.exceptions.DBusException:
            print(status + ' is not supported by ' + valid_account)
            print simple_presence

main()

when I run this script,
I get the following error.

phanindra@phanindra:~$ python clementine.py 
onelove - Blue

(clementine.py:6142): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap",
onelove - Blue is not supported by /org/freedesktop/Telepathy/Account/gabble/jabber/abcd_40gmail_2ecom0

I did something wrong? or the functions are deprecated?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:05:08+00:00Added an answer on May 26, 2026 at 9:05 pm

    Try this to update the status of Empathy with the current track playing in Clementine:

    import dbus
    session_bus = dbus.SessionBus()
    player = session_bus.get_object('org.mpris.clementine', '/Player')
    iface = dbus.Interface(player, dbus_interface='org.freedesktop.MediaPlayer')
    metadata = iface.GetMetadata()
    status = "♫ ".decode('utf8')+metadata["title"]+' - '+metadata["album"]+" ♫".decode('utf8')
    print status
    from gi.repository import TelepathyGLib as Tp
    from gi.repository import GObject
    loop = GObject.MainLoop()
    am = Tp.AccountManager.dup()
    am.prepare_async(None, lambda *args: loop.quit(), None)
    loop.run()
    am.set_all_requested_presences(Tp.ConnectionPresenceType.AVAILABLE,
    'available', status)
    

    Thank you for updating the Format in my original post !
    – Harsha

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.