Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am working o a script that will automatically change the Gnome Shell integrated chat/messaging status to "unavailable" when the screen is locked, or the gnome-screensaver is activated.

Anyone knows what is the terminal command that sets the gnome messaging system status to "available" or "unavailable"?

I have tried addons on pidgin and empathy, but it seems like the gnome messaging status does not depend on these.

share|improve this question
up vote 5 down vote accepted

got it to work! simple python script:


import os
import time
import dbus
session_bus = dbus.SessionBus()
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)

screensaver_started = 0
running = 0

while 1:
        active = 0
    out = ""
    pid = 0

    if screensaver_started == 0:
        # Don't do anything if the screensaver isn't running
        s = os.popen("pidof gnome-screensaver")
        spid =
        if len(spid) > 0:
            screensaver_started = 1
        h = os.popen("gnome-screensaver-command -q", "r")
        out =
        active = out.find("inactive")

        if active < 0 and running == 0:
            am.set_all_requested_presences(Tp.ConnectionPresenceType.OFFLINE, 'Offline', "")
            running = 1
        elif active > 0 and running == 1:
            am.set_all_requested_presences(Tp.ConnectionPresenceType.AVAILABLE, 'available', "")
            running = 0

this script will automatically set status to "unavailable" when screen is locked or screensaver is activated, and will bring it back to available (online) when screensaver is closed!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.