tz1
|
2009-01-28
, 18:58
|
|
Posts: 716 |
Thanked: 236 times |
Joined on Dec 2007
|
#11
|
|
2009-01-28
, 20:01
|
|
Posts: 716 |
Thanked: 236 times |
Joined on Dec 2007
|
#12
|
#!/usr/bin/env python2.5 from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) import dbus import gobject import os class bthssetup(): def __init__(self): self.m_loop = DBusGMainLoop() self.bus = dbus.SystemBus(mainloop = self.m_loop, private = True) self.bus.add_signal_receiver(self.discharge,signal_name = "charger_disconnected", dbus_interface = "com.nokia.bme.signal", path = "/com/nokia/bme/signal" ) self.bus.add_signal_receiver(self.charge ,signal_name="charger_connected", dbus_interface = "com.nokia.bme.signal", path = "/com/nokia/bme/signal" ) def charge(self,sender=None): os.system('dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.play') def discharge(self,sender=None): os.system('dbus-send --dest=com.nokia.osso_media_server /com/nokia/osso_media_server com.nokia.osso_media_server.music.pause') #------------------------------------------------------------------------ def run(self): dbus_loop = gobject.MainLoop() dbus_loop.run() if __name__ == "__main__": app = bthssetup() app.run()
The Following User Says Thank You to tz1 For This Useful Post: | ||
|
2009-01-28
, 20:03
|
|
Posts: 716 |
Thanked: 236 times |
Joined on Dec 2007
|
#13
|
|
2009-01-29
, 10:32
|
Posts: 6 |
Thanked: 2 times |
Joined on Jan 2009
|
#14
|
|
2009-01-29
, 21:00
|
|
Posts: 716 |
Thanked: 236 times |
Joined on Dec 2007
|
#15
|
|
2009-02-24
, 00:02
|
Posts: 118 |
Thanked: 59 times |
Joined on May 2007
|
#16
|
#!/bin/sh #Use Internet Tablet with XMMS as car stereo source #pauses when external power is removed; rewinds 10 seconds & resumes play when restored #sets system master volume to 100 when output jack is connected/disconnected #requires xmms and xmmsctrl #tested on N800 with OS2008 5.2008.43-7, bash2 dbus-monitor --system "member='charger_connected'" > charge_on.txt & dbus-monitor --system "member='charger_disconnected'" > charge_off.txt & dbus-monitor --system "path='/org/freedesktop/Hal/devices/platform_headphone'" > phone_plug.txt & if xmmsctrl running then xmmsctrl play else xmmsctrl launch xmmsctrl play fi sleep 3 #flush initial messages echo > charge_on.txt echo > charge_off.txt echo > phone_plug.txt gconftool -t int -s /apps/osso/sound/master_volume 100 #continue monitoring until xmms is terminated while `xmmsctrl running` do chargeon=`wc -c charge_on.txt | cut -b1-10` chargeoff=`wc -c charge_off.txt | cut -b1-10` phoneplug=`wc -c phone_plug.txt | cut -b1-10` if [ "$chargeoff" -gt 1 ] then xmmsctrl pause echo > charge_off.txt elif [ "$phoneplug" -gt 1 ] then gconftool -t int -s /apps/osso/sound/master_volume 100 echo > phone_plug.txt elif [ "$chargeon" -gt 1 ] then if xmmsctrl paused then xmmsctrl time -10 xmmsctrl play fi echo > charge_on.txt fi sleep 3 done #following line kills all running dbus-monitor processes; comment out if any in use besides the 3 in this script killall dbus-monitor