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
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.
~/empathy_signout.py) and then schedule your task to call that (
python ~/empathy_signout.py). Replace the string
EXAMPLE in the fourth line with your Google Talk account name before you save the file.
# Disconnect Empathy from Google Talk and kill the program.
# Replace EXAMPLE below with your account name (whatever is before @gmail.com)
google_acct_name = 'EXAMPLE'
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)
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.