User:Alef

From Openmoko

Jump to: navigation, search

Contents

Useful scripts

  • enable/disable suspend
  • enable/disable display blanking/dimming
  • turn on/off gps

Tested on Om 2008.12 and SHR-testing 2009-03-03.

Enable/disable suspend

/usr/local/bin/set_suspend.sh:

#!/bin/sh

systemname="$1"
setto="$2"

# setto=off ... stop suspending for $systemname
# setto=on  ... ok to suspend for $systemname

export DISPLAY=:0

if [ "$setto" = "on" ]; then
	# ok to suspend
	if [ -d /etc/freesmartphone ]; then
		mdbus -s org.shr.ophonekitd.Usage /org/shr/ophonekitd/Usage \
			ReleaseResource CPU
	else
		dbus-send --system --dest=org.openmoko.Power / org.openmoko.Power.Core.RemoveRequestedResourceState \
			string:cpu string:$systemname
	fi
else
	# avoid suspend
	if [ -d /etc/freesmartphone ]; then
		mdbus -s org.shr.ophonekitd.Usage /org/shr/ophonekitd/Usage \
			RequestResource CPU
	else
		dbus-send --system --dest=org.openmoko.Power / org.openmoko.Power.Core.RequestResourceState \
			string:cpu string:$systemname string:on
	fi
fi

Enable/disable display

/usr/local/bin/set_display.sh:

#!/bin/sh

setto="$1"

# setto=off ... switch display off/turn xlock on
# setto=on  ... switch display on/turn xlock off

export DISPLAY=:0

if [ "$setto" = "on" ]; then
	# display on/xlock off
	if [ -d /etc/freesmartphone ]; then
		mdbus -s org.shr.ophonekitd.Usage /org/shr/ophonekitd/Usage \
			RequestResource Display
	else
		xset s off
	fi
else
	# display off/xlock on
	if [ -d /etc/freesmartphone ]; then
		mdbus -s org.shr.ophonekitd.Usage /org/shr/ophonekitd/Usage \
			ReleaseResource Display
	else
		xset s 60 5
	fi
fi

Enable/disable GPS

/usr/local/bin/set_gps.sh:

#!/bin/sh

setto="$1"

# setto=off ... switch gps on
# setto=on  ... switch gps off

if [ "$setto" = "on" ]; then
        # gps on
        if [ -d /etc/freesmartphone ]; then
                if [ -e /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-regltr.7/neo1973-pm-gps.0/pwron ]; then
                    echo 1 > /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-regltr.7/neo1973-pm-gps.0/pwron
                else
                    echo 0 > /sys/bus/platform/devices/neo1973-pm-gps.0/power_on
                fi
        else
                echo 1 > /sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron
        fi
else
        # gps off
        if [ -d /etc/freesmartphone ]; then
                if [ -e /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-regltr.7/neo1973-pm-gps.0/pwron ]; then
                    echo 0 > /sys/class/i2c-adapter/i2c-0/0-0073/pcf50633-regltr.7/neo1973-pm-gps.0/pwron
                else
                    echo 0 > /sys/bus/platform/devices/neo1973-pm-gps.0/power_on
                fi
        else
                echo 0 > /sys/devices/platform/s3c2440-i2c/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron
        fi
fi

Scripts used for TangoGPS

/usr/local/bin/tangogps.sh:

#!/bin/sh

PATH=$PATH:/usr/local/bin

set_gps.sh on
set_suspend.sh application-tangogps
set_display.sh on

tangogps "$@"

set_display.sh off
set_suspend.sh application-tangogps on
set_gps.sh off
Personal tools