View Single Post
Posts: 50 | Thanked: 120 times | Joined on Apr 2010 @ Poland
#2
One more thing. Handy if you don't need your N900 to be online at all times and, in fact, prefer it to be mostly offline (except when you actually use it hands-on). It activates offline mode on device lock -- unless there's wlan/gprs connection active or bluetooth is on -- and reverts to normal mode on device unlock. Relies on dbus-scripts.

/etc/dbus-scripts.d/tklock:
Code:
/usr/sbin/offline * * com.nokia.mce.signal tklock_mode_ind locked
/usr/sbin/online * * com.nokia.mce.signal tklock_mode_ind unlocked
/usr/sbin/online:
Code:
#!/bin/sh

PMODE=`dbus-send --system --print-reply --dest=com.nokia.mce --type=method_call /com/nokia/mce/request com.nokia.mce.request.get_device_mode | grep normal`

if [ -z "$PMODE" ]; then
    dbus-send --system --dest=com.nokia.mce --type=method_call /com/nokia/mce/request com.nokia.mce.request.req_device_mode_change string:"normal"
else
    GONLINE=`dbus-send --system --print-reply --dest=com.nokia.phone.SSC --type=method_call --print-reply /com/nokia/phone/SSC com.nokia.phone.SSC.get_modem_state | grep online`
    if [ -z "$GONLINE" ]; then
	dbus-send --system --dest=com.nokia.phone.SSC --type=method_call --print-reply /com/nokia/phone/SSC com.nokia.phone.SSC.set_radio boolean:true
    fi
fi
/usr/sbin/offline:
Code:
#!/bin/sh

WCONN=`dbus-send --system --dest=com.nokia.wlancond --type=method_call --print-reply /com/nokia/wlancond/request com.nokia.wlancond.request.connection_status | grep "true"`
GCONN=`dbus-send --system --dest=com.nokia.csd.GPRS --type=method_call --print-reply /com/nokia/csd/gprs/0 com.nokia.csd.GPRS.Context.GetStatus | grep "true"`
BCONN=`dbus-send --system --print-reply --type=method_call --dest=org.bluez $(dbus-send --system --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter | awk -F'"' '/at/ {print $2}') org.bluez.Adapter.GetProperties | grep -A 1 Powered | grep true`
MON=`iwconfig | grep "Mode:Monitor"`

if [ -z "$WCONN" ] && [ -z "$GCONN" ] && [ -z "$BCONN" ] && [ -z "$MON" ]; then
    dbus-send --system --dest=com.nokia.mce --type=method_call /com/nokia/mce/request com.nokia.mce.request.req_device_mode_change string:"offline"
else
    if [ -z "$GCONN" ]; then
	dbus-send --system --dest=com.nokia.phone.SSC --type=method_call --print-reply /com/nokia/phone/SSC com.nokia.phone.SSC.set_radio boolean:false
    fi
fi
__________________
.:different kinds of pop

Last edited by trompkins; 2012-12-03 at 01:09.
 

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