User:Morlac
From Openmoko
(extended - →hardware-switches and misc for bash) |
m (→hardware-switches and misc for bash) |
||
Line 98: | Line 98: | ||
=== bluetooth-gps-relay === | === bluetooth-gps-relay === | ||
− | + | #!/bin/bash | |
− | #!/bin/bash | + | |
− | + | # (c) Copyright 2009 Christian Adams <morlac@morlac.de> | |
− | # (c) Copyright 2009 Christian Adams <morlac@morlac.de> | + | # GPL V2 or later |
− | # GPL V2 or later | + | |
− | + | # set -x | |
− | # set -x | + | |
− | + | HCITOOL="hcitool" | |
− | HCITOOL="hcitool" | + | HCITOOL_BIN=`which ${HCITOOL}` |
− | HCITOOL_BIN=`which ${HCITOOL}` | + | RFCOMM="rfcomm" |
− | RFCOMM="rfcomm" | + | RFCOMM_BIN=`which ${RFCOMM}` |
− | RFCOMM_BIN=`which ${RFCOMM}` | + | SDPTOOL="sdptool" |
− | SDPTOOL="sdptool" | + | SDPTOOL_BIN=`which ${SDPTOOL}` |
− | SDPTOOL_BIN=`which ${SDPTOOL}` | + | |
− | + | test -x ${HCITOOL_BIN} || exit 0 | |
− | test -x ${HCITOOL_BIN} || exit 0 | + | test -x ${RFCOMM_BIN} || exit 0 |
− | test -x ${RFCOMM_BIN} || exit 0 | + | test -x ${SDPTOOL_BIN} || exit 0 |
− | test -x ${SDPTOOL_BIN} || exit 0 | + | |
− | + | BT_ADDR=`${HCITOOL_BIN} dev |grep hci|awk '{print $2}'` | |
− | BT_ADDR=`${HCITOOL_BIN} dev |grep hci|awk '{print $2}'` | + | |
− | + | if [ "x${BT_ADDR}" == "x" ] ; then | |
− | if [ "x${BT_ADDR}" == "x" ] ; then | + | |
echo "no bloutooth-device available - exiting" | echo "no bloutooth-device available - exiting" | ||
exit 0 | exit 0 | ||
− | fi | + | fi |
− | + | ||
− | PID_FILE=/var/run/gps_relay.pid | + | PID_FILE=/var/run/gps_relay.pid |
− | + | ||
− | CHANNEL="1" | + | CHANNEL="1" |
− | + | ||
− | PID="" | + | PID="" |
− | test -f ${PID_FILE} && . ${PID_FILE} | + | test -f ${PID_FILE} && . ${PID_FILE} |
− | + | ||
− | do_start() { | + | do_start() { |
if [ "x${PID}" == "x" ] ; then | if [ "x${PID}" == "x" ] ; then | ||
echo "starting gps-bluetooth-relay on bt-channel 1" | echo "starting gps-bluetooth-relay on bt-channel 1" | ||
${SDPTOOL_BIN} add --channel ${CHANNEL} --handle 0x424242 SP | ${SDPTOOL_BIN} add --channel ${CHANNEL} --handle 0x424242 SP | ||
− | + | ||
${RFCOMM_BIN} -r watch 0 ${CHANNEL} sh -c "gpspipe -r >/dev/rfcomm0" & | ${RFCOMM_BIN} -r watch 0 ${CHANNEL} sh -c "gpspipe -r >/dev/rfcomm0" & | ||
PID=$! | PID=$! | ||
− | + | ||
echo "PID=${PID}" > ${PID_FILE} | echo "PID=${PID}" > ${PID_FILE} | ||
else | else | ||
echo "not starting - stale pidfile (${PID_FILE}) or allready running with pid ${PID}" | echo "not starting - stale pidfile (${PID_FILE}) or allready running with pid ${PID}" | ||
fi | fi | ||
− | } | + | } |
− | + | ||
− | is_running() { | + | is_running() { |
test -f ${PID_FILE} || return 0 | test -f ${PID_FILE} || return 0 | ||
− | + | ||
running=`ps x|grep ${PID}|awk '{print $5}'` | running=`ps x|grep ${PID}|awk '{print $5}'` | ||
running=`echo $running|awk '{print $1}'` | running=`echo $running|awk '{print $1}'` | ||
− | + | ||
if [ "x${running}" == "x${RFCOMM_BIN}" ] ; then | if [ "x${running}" == "x${RFCOMM_BIN}" ] ; then | ||
return 1 | return 1 | ||
fi | fi | ||
− | + | ||
return 0 | return 0 | ||
− | } | + | } |
− | + | ||
− | do_stop() { | + | do_stop() { |
is_running | is_running | ||
if [ "x$?" == "x1" ] ; then | if [ "x$?" == "x1" ] ; then | ||
echo "stoping gps-bluetooth-relay .." | echo "stoping gps-bluetooth-relay .." | ||
${SDPTOOL_BIN} del 0x424242 | ${SDPTOOL_BIN} del 0x424242 | ||
− | + | ||
kill -9 ${PID} | kill -9 ${PID} | ||
rm ${PID_FILE} | rm ${PID_FILE} | ||
Line 169: | Line 168: | ||
echo "not running - not halting .." | echo "not running - not halting .." | ||
fi | fi | ||
− | } | + | } |
− | + | ||
− | case "${1}" in | + | case "${1}" in |
− | (start) | + | (start) |
do_start | do_start | ||
;; | ;; | ||
− | (stop) | + | (stop) |
do_stop | do_stop | ||
;; | ;; | ||
− | (restart) | + | (restart) |
do_stop | do_stop | ||
do_start | do_start | ||
;; | ;; | ||
− | (status) | + | (status) |
is_running | is_running | ||
if [ "x$?" == "x1" ] ; then | if [ "x$?" == "x1" ] ; then | ||
Line 190: | Line 189: | ||
fi | fi | ||
;; | ;; | ||
− | esac | + | esac |
− | + | ||
− | exit 0 | + | exit 0 |
== workaround for apm with debian@FR == | == workaround for apm with debian@FR == |
Latest revision as of 15:26, 27 January 2009
Contents |
[edit] hardware-switches and misc for bash
[edit] bt_hardware
#!/bin/sh BT_HW="/sys/bus/platform/devices/neo1973-pm-bt.0/power_on" BT_RST="/sys/bus/platform/devices/neo1973-pm-bt.0/reset" [ -e "${BT_HW}" ] || exit 0 case "${1}" in (start) echo 1 > ${BT_HW} echo 0 > ${BT_RST} echo "BlueTooth-Hardware is now on" ;; (stop) echo 0 > ${BT_HW} echo "BlueTooth-Hardware is now off" ;; (status) BT_STATUS=`cat ${BT_HW}` case "${BT_STATUS}" in ("1") echo "BlueTooth-Hardware is on" ;; ("0") echo "BlueTooth-Hardware is off" ;; esac ;; esac exit 0
[edit] gps_hardware
#!/bin/sh GPS_HW="/sys/class/i2c-adapter/i2c-0/0-0073/neo1973-pm-gps.0/pwron" [ -e "${GPS_HW}" ] || exit 0 case "${1}" in (start) echo 1 > ${GPS_HW} echo "GPS-Hardware is now on" ;; (stop) echo 0 > ${GPS_HW} echo "GPS-Hardware is now off" ;; (status) GPSSTATUS=`cat ${GPS_HW}` case "${GPSSTATUS}" in ("1") echo "GPS-Hardware is on" ;; ("0") echo "GPS-Hardware is off" ;; esac ;; esac exit 0
[edit] gsm_hardware
#!/bin/sh GSM_HW="/sys/bus/platform/devices/neo1973-pm-gsm.0/power_on" [ -e "${GSM_HW}" ] || exit 0 case "${1}" in (start) echo 1 > ${GSM_HW} echo "GSM-Hardware is now on" ;; (stop) echo 0 > ${GSM_HW} echo "GSM-Hardware is now off" ;; (status) GSM_STATUS=`cat ${GSM_HW}` case "${GSM_STATUS}" in ("1") echo "GSM-Hardware is on" ;; ("0") echo "GSM-Hardware is off" ;; esac ;; esac exit 0
[edit] wifi_hardware
(planned but not available yet)
[edit] bluetooth-gps-relay
#!/bin/bash # (c) Copyright 2009 Christian Adams <morlac@morlac.de> # GPL V2 or later # set -x HCITOOL="hcitool" HCITOOL_BIN=`which ${HCITOOL}` RFCOMM="rfcomm" RFCOMM_BIN=`which ${RFCOMM}` SDPTOOL="sdptool" SDPTOOL_BIN=`which ${SDPTOOL}` test -x ${HCITOOL_BIN} || exit 0 test -x ${RFCOMM_BIN} || exit 0 test -x ${SDPTOOL_BIN} || exit 0 BT_ADDR=`${HCITOOL_BIN} dev |grep hci|awk '{print $2}'` if [ "x${BT_ADDR}" == "x" ] ; then echo "no bloutooth-device available - exiting" exit 0 fi PID_FILE=/var/run/gps_relay.pid CHANNEL="1" PID="" test -f ${PID_FILE} && . ${PID_FILE} do_start() { if [ "x${PID}" == "x" ] ; then echo "starting gps-bluetooth-relay on bt-channel 1" ${SDPTOOL_BIN} add --channel ${CHANNEL} --handle 0x424242 SP ${RFCOMM_BIN} -r watch 0 ${CHANNEL} sh -c "gpspipe -r >/dev/rfcomm0" & PID=$! echo "PID=${PID}" > ${PID_FILE} else echo "not starting - stale pidfile (${PID_FILE}) or allready running with pid ${PID}" fi } is_running() { test -f ${PID_FILE} || return 0 running=`ps x|grep ${PID}|awk '{print $5}'` running=`echo $running|awk '{print $1}'` if [ "x${running}" == "x${RFCOMM_BIN}" ] ; then return 1 fi return 0 } do_stop() { is_running if [ "x$?" == "x1" ] ; then echo "stoping gps-bluetooth-relay .." ${SDPTOOL_BIN} del 0x424242 kill -9 ${PID} rm ${PID_FILE} else echo "not running - not halting .." fi } case "${1}" in (start) do_start ;; (stop) do_stop ;; (restart) do_stop do_start ;; (status) is_running if [ "x$?" == "x1" ] ; then echo "gps-bluetooth-relay running" else echo "gps_bluetooth-relay not running" fi ;; esac exit 0
[edit] workaround for apm with debian@FR
first: turn off apmd
what's actually running for me is:
mv /usr/bin/apm /usr/bin/apm.o and create new /usr/bin/apm as follows:
[edit] /usr/bin/apm
#!/bin/sh echo 1 > /sys/module/glamo_mci/parameters/sd_idleclk apm.o ${*} echo 0 > /sys/module/glamo_mci/parameters/sd_idleclk
Another script:
add link /etc/apm/event.d (don't forget to chmod +x /etc/apm/scripts.d/sd_idleclk)
[edit] /etc/apm/scripts.d/sd_idleclk
#!/bin/sh SD_IDLECLK="/sys/module/glamo_mci/parameters/sd_idleclk" [ -x "${SD_IDLECLK}" ] || exit 0 case "${1},${2}" in (suspend,*) echo 1 > ${SD_IDLECLK} touch /etc ;; (resume,suspend) echo 0 > ${SD_IDLECLK} ;; esac # for debugging: echo "${1}, ${2} - `date`" >> /tmp/apm.log sleep 1 sync exit 0
[edit] Linklist
http://wiki.openmoko.org/wiki/Switching_Keyboards
http://wiki.openmoko.org/wiki/Boot_from_sd_card
http://wiki.openmoko.org/wiki/Lint-wifi
http://hdr.meetr.de/neo/openmoko/battery
http://www.ohli.de/download/openmoko-panel-plugin_0.1-1_all.deb
New Images for panel-plugin: (and patch for panel-plugin to provide keyboard-toggle Media:Panel-plugin.patch.txt)
http://www.ohli.de/download/xserver-xorg-input-tslib_0.0.5-1+fso1_armel.deb
Option "EmulateRightButton" "1"
[edit] Location
Trier, Germany
[edit] Contact
-----BEGIN CONTACT BLOCK----- eMail: morlac@morlac.de Jabber:morlac@skavaer.homelinux.org ------END CONTACT BLOCK------ -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS$/IT;d-;s:;a?;C++(+++)>++++;UL++++;P++(+++)>++++; L++(+++);E---;W++;N(+);o?;K?;!w;!O;!M+>;!V;PS(+);PE; Y+;PGP++;t+(++);5(+)>++;X(+);R*;tv->+;b++(+++);DI++; D++(+++)>++++;G(+)>++;e+>+++;h-()>++;r++;y++; ------END GEEK CODE BLOCK------ Key-ID: 2949CB31 http://pgpkeys.pca.dfn.de/pks/lookup?search=0x2949CB31&fingerprint=on&op=vindex