View Single Post
Posts: 11 | Thanked: 31 times | Joined on Nov 2008 @ Denmark
#5
I've toyed with the idea of autoaway myself and have so far created this little python "daemon"

(This Work in progess, I take no resposibility to what might happen to your device. Use it at your own cost and peril)

PHP Code:
#!/usr/bin/python
import threading
import dbus
gobject
import gtk
from dbus
.mainloop.glib import DBusGMainLoop
import telepathy
.constants

awaydelay
=5
xmppaccount
="/org/freedesktop/Telepathy/Account/gabble/jabber/****_40gmail_2ecom0"

def timer_callback():
   print 
"screen has been off for defined number of  seconds"
   
sessionbus dbus.SessionBus()   
   
gmailobj sessionbus.get_object('org.freedesktop.Telepathy.AccountManager'xmppaccount)
   
gmailinterface=dbus.Interface(gmailobj'org.freedesktop.DBus.Properties')
   
gmailstruct=dbus.Struct((dbus.UInt32(telepathy.constants.CONNECTION_PRESENCE_TYPE_AWAY), '''autoaway'))
   
gmailinterface.Set('org.freedesktop.Telepathy.Account''RequestedPresence'gmailstruct)

screentimer threading.Timer(awaydelaytimer_callback)

def screen_callback(value):
   print 
"screen is:"value
   
if value == "off":
      
screentimer.__init__(awaydelaytimer_callback)
      
screentimer.start()
   if 
value == "on":
      
screentimer.cancel()

#Main loop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus dbus.SystemBus()

bus.add_signal_receiver(screen_callback,
                        
dbus_interface="com.nokia.mce.signal",
                        
signal_name="display_status_ind")

gtk.gdk.threads_init()

loop gobject.MainLoop()
loop.run() 
It listens on the DBUS for status of the screen. When the screen has been off for "awaydelay" seconds, it sets (again through DBUS) "xmppaccount" away. It doesn't bring the account back online when the screen is turned on again in the current state.

If you would like to test it out:

1) Save the contents of the above to a file e.g. called n900autoaway.py on your device, install one ekstra package called python-telepathy (which is required).

2) Edit the "awaydelay" and "xmmpaccount" to suit you. A list of conversation DBUS names for you Conversation accounts can be obtained through:

Code:
/usr/bin/dbus-send --type=method_call --print-reply --dest=org.freedesktop.Telepathy.AccountManager /org/freedesktop/Telepathy/AccountManager org.freedesktop.DBus.Properties.Get string:org.freedesktop.Telepathy.AccountManager string:ValidAccounts
3) Once edited you start it from the terminal with:

python n900autoaway.py.

Take it as it is. Maybe I'll improve it, maeybe I won't. Make suggestions, make improvements, make whatever :-)

Best regards,
Lasse

PS: btw I have no idea if this works with skype accounts so this may be off topic
 

The Following 4 Users Say Thank You to lasseaagren For This Useful Post: