Notices


Reply
Thread Tools
Posts: 19 | Thanked: 7 times | Joined on Dec 2009
#1
i (and a lot more, i guess) would like to have some script/application which kills or starts "high load" network stuff like skype. it should kill (send offline) skype when i leave my wlan or usb-lan and restart it when i connect to it again. this mechanism could save a lot of traffic for dataplan/noflat users.

i was told that this should be possible via dbus, but my dbus knowledge is very limited.

is anyone willing to implement that or is it impossible?

tia mortak
 

The Following User Says Thank You to mortak For This Useful Post:
Posts: 228 | Thanked: 145 times | Joined on Dec 2009
#2
that's brilliant

+1
 
Posts: 21 | Thanked: 8 times | Joined on Dec 2009
#3
Ok heres a python script to set status to offline on skype at Wlan disconnect. I can't test completely right now as I am roaming, so try it out and let me know.
Code:
import gobject
import dbus
from dbus.mainloop.glib import DBusGMainLoop

import subprocess

def Wlan_StDis(interf):
	acc_r=subprocess.Popen('/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 | grep -m 1 skype', shell=True, stdout=subprocess.PIPE, ).communicate()[0]
	acc = acc_r[22:-2]
	print acc
	bus= dbus.SessionBus()
	accm = bus.get_object('org.freedesktop.Telepathy.AccountManager', acc)
	accm.Set('org.freedesktop.Telepathy.Account', 'RequestedPresence', \
		dbus.Struct(( dbus.UInt32(1) ,  'Offline', 'Disconnect by script' ), signature='uss'),
		dbus_interface='org.freedesktop.DBus.Properties')
DBusGMainLoop(set_as_default=True)
dbus.SystemBus().add_signal_receiver(Wlan_StDis,dbus_interface=None,signal_name="disconnected",bus_name="com.nokia.wlancond",path="/com/nokia/wlancond/signal",)
gobject.MainLoop().run()

Last edited by VII; 2010-07-14 at 08:04. Reason: Fixed code 1
 

The Following 2 Users Say Thank You to VII For This Useful Post:
Posts: 1 | Thanked: 0 times | Joined on Jul 2010
#4
How should I be testing this?
 
cjp's Avatar
Posts: 762 | Thanked: 395 times | Joined on Jan 2010 @ Helsinki
#5
Man, I'd really like the dev of AutoDisconnect to pick this feature up.

I'm really vouching for that app to become the ultimate connections manager for Maemo. VII, would you be interested in dropping that line to the AutoDisconnect developer?
 
Posts: 21 | Thanked: 8 times | Joined on Dec 2009
#6
Originally Posted by Trucker Her View Post
How should I be testing this?
Save the script to your device, then run it from terminal.
rootsh required
python2.5 required
need to be root
need to chmod a+x in terminal for the script

ex:
/usr/bin/python2.5 /home/user/ScriptName.py
 
Posts: 21 | Thanked: 8 times | Joined on Dec 2009
#7
Originally Posted by cjp View Post
Man, I'd really like the dev of AutoDisconnect to pick this feature up.

I'm really vouching for that app to become the ultimate connections manager for Maemo. VII, would you be interested in dropping that line to the AutoDisconnect developer?
Sure anyone who wants to make something of this script is encouraged.
As of right now it is not fully tested!
Futher I do not know if AutoDisconnect is writen in python or if the developer will like the way this works.
 
Posts: 68 | Thanked: 16 times | Joined on Feb 2007
#8
Originally Posted by VII View Post
Sure anyone who wants to make something of this script is encouraged.
As of right now it is not fully tested!
Futher I do not know if AutoDisconnect is writen in python or if the developer will like the way this works.
The backend work in AutoDisconnect is actually Bash, but I see no big issues in recalling your script from within AD.

I'm gonna patch the backend scripts later today, but I'd need some help from Aymeric (AD developer) in order to modify admin GUI.

Stay tuned.
 
Posts: 68 | Thanked: 16 times | Joined on Feb 2007
#9
I'm also considering adding a list of apps to start/kill on start/stop of data connection...
 
Posts: 21 | Thanked: 8 times | Joined on Dec 2009
#10
Ok great, glad some of my spare time is being usefull
 
Reply


 
Forum Jump


All times are GMT. The time now is 07:34.