Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

How to achieve auto login and log off on Google accounts on time based . I am using the chat client is EMPATHY

share|improve this question
up vote 6 down vote accepted

First you'll need a way to schedule tasks. If you're not familiar with cron, and you're using Ubuntu/GNOME then sudo apt-get install gnome-schedule. Then you can open Scheduled Tasks from the System >> Preferences menu and use the GUI to set a specific time for a command to run.

The simplest way to schedule a time for Empathy to connect and disconnect is to just schedule jobs to start and stop the program (just use the commands empathy and killall empathy). The problem is that if we kill Empathy without logging out then you'll still appear signed in for a few minutes until Google discovers that you've timed out.

To get around that problem we can use D-Bus to send a signal to Empathy's backend that asks it to disconnect. There are lots of ways to do this including with dbus-send from the command line, but since I'm more familiar with Python I used that.

Instead of configuring your sign-off task to call killall empathy, save the following script somewhere (e.g. ~/ and then schedule your task to call that (python ~/ Replace the string EXAMPLE in the fourth line with your Google Talk account name before you save the file.

#!/usr/bin/env python
# Disconnect Empathy from Google Talk and kill the program.

# Replace EXAMPLE below with your account name (whatever is before
google_acct_name = 'EXAMPLE'

import os
    import dbus
except ImportError:
   exit('You need the Python dbus bindings,'
        ' type "sudo apt-get install python-dbus".')

wkname = ('org.freedesktop.Telepathy.Connection.gabble.jabber.' + 
          google_acct_name + '_40gmail_2ecom_2fTelepathy')
pathname = '/' + wkname.replace('.', '/')

bus = dbus.SessionBus()
conn_obj = bus.get_object(wkname, pathname)

os.system('killall empathy')

This script could be tweaked to avoid the hacky guess of the account name path component, or to sign on also (If quitting the program is a problem). Take a look at the ConnectionManager interface in the Telepathy D-Bus docs if this stuff doesn't frighten you.

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.