From 1bccfc2c0f3c16d6d45362de805a560d5c8db241 Mon Sep 17 00:00:00 2001 From: David-John Willis Date: Wed, 30 Dec 2009 12:13:56 +0000 Subject: [PATCH 1/1] pandora-scripts: Start to add scripts for turning on/off Bluetooth and WiFi (WIP). --- recipes/pandora-system/pandora-scripts.bb | 14 ++++++-- .../pandora-scripts/op_bluetooth.desktop | 9 +++++ .../pandora-scripts/op_bluetooth.sh | 24 +++++++++++++ .../pandora-scripts/op_wifi.desktop | 9 +++++ .../pandora-system/pandora-scripts/op_wifi.sh | 34 +++++++++++++++++++ 5 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 recipes/pandora-system/pandora-scripts/op_bluetooth.desktop create mode 100644 recipes/pandora-system/pandora-scripts/op_bluetooth.sh create mode 100644 recipes/pandora-system/pandora-scripts/op_wifi.desktop create mode 100644 recipes/pandora-system/pandora-scripts/op_wifi.sh diff --git a/recipes/pandora-system/pandora-scripts.bb b/recipes/pandora-system/pandora-scripts.bb index 1103285..673de3a 100644 --- a/recipes/pandora-system/pandora-scripts.bb +++ b/recipes/pandora-system/pandora-scripts.bb @@ -6,22 +6,30 @@ COMPATIBLE_MACHINE = "omap3-pandora" DEPENDS = "zenity dbus" RDEPENDS = "zenity dbus" -PR = "r1" +PR = "r2" SRC_URI = " \ file://op_bright.sh \ file://op_bright.desktop \ file://op_cpuspeed.sh \ file://op_cpuspeed.desktop \ + file://op_wifi.sh \ + file://op_wifi.desktop \ + file://op_bluetooth.sh \ + file://op_bluetooth.desktop \ " do_install() { install -d ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_bright.sh ${D}${prefix}/pandora/scripts/ - install -m 0755 ${WORKDIR}/op_cpuspeed.sh ${D}${prefix}/pandora/scripts/ + install -m 0755 ${WORKDIR}/op_cpuspeed.sh ${D}${prefix}/pandora/scripts/ + install -m 0755 ${WORKDIR}/op_wifi.sh ${D}${prefix}/pandora/scripts/ + install -m 0755 ${WORKDIR}/op_bluetooth.sh ${D}${prefix}/pandora/scripts/ install -d ${D}${datadir}/applications/ install -m 0644 ${WORKDIR}/op_bright.desktop ${D}${datadir}/applications/ - install -m 0644 ${WORKDIR}/op_cpuspeed.desktop ${D}${datadir}/applications/ + install -m 0644 ${WORKDIR}/op_cpuspeed.desktop ${D}${datadir}/applications/ + install -m 0644 ${WORKDIR}/op_wifi.desktop ${D}${datadir}/applications/ + install -m 0644 ${WORKDIR}/op_bluetooth.desktop ${D}${datadir}/applications/ } PACKAGE_ARCH = "${MACHINE_ARCH}" diff --git a/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop b/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop new file mode 100644 index 0000000..e1f30f4 --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_bluetooth.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Toggle Bluetooth +Comment=Toggle the status of your Bluetooth device. +StartupNotify=false +Exec=/usr/pandora/scripts/op_bluetooth.sh +Icon=Terminal +Terminal=false +Type=Application +Categories=System; diff --git a/recipes/pandora-system/pandora-scripts/op_bluetooth.sh b/recipes/pandora-system/pandora-scripts/op_bluetooth.sh new file mode 100644 index 0000000..d66c245 --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_bluetooth.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# +# Released under the GPL + +SILENT=0 +while getopts s opt +do + case "$opt" in + s) SILENT=1;; + esac +done + +INTERFACE=`hciconfig | grep "^hci" | cut -d ':' -f 1` +pgrep bluetoothd +if [ $? = 1 ]; then + notify-send "Bluetooth" "The bluetooth interface is being set up..." -i /usr/share/icons/hicolor/32x32/apps/st_bluetooth.png + sudo /usr/sbin/hciconfig ${INTERFACE} down + sudo /usr/sbin/hciconfig ${INTERFACE} up pscan + sudo /usr/sbin/bluetoothd +fi + +if [ ${SILENT} = 0 ]; then + bluetooth-wizard +fi diff --git a/recipes/pandora-system/pandora-scripts/op_wifi.desktop b/recipes/pandora-system/pandora-scripts/op_wifi.desktop new file mode 100644 index 0000000..dde2df7 --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_wifi.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Toggle WiFi +Comment=Toggle the status of the WiFi chip. +StartupNotify=false +Exec=/usr/pandora/scripts/op_wifi.sh +Icon=Terminal +Terminal=false +Type=Application +Categories=System; diff --git a/recipes/pandora-system/pandora-scripts/op_wifi.sh b/recipes/pandora-system/pandora-scripts/op_wifi.sh new file mode 100644 index 0000000..3f2c65b --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_wifi.sh @@ -0,0 +1,34 @@ +#!/bin/bash +#get value range +minmhz=14 +safemhz=600 +maxmhz=900 +curmhz=$(cat /proc/pandora/cpu_mhz_max) +device=/proc/pandora/cpu_mhz_max +if [ ! $1 ]; then + if [ $DISPLAY ]; then + newmhz=$(zenity --scale --text "set cpu mhz" --min-value=$minmhz --max-value=$maxmhz --value=$curmhz --step 1) + else + newmhz=$(read -p "Pleas enter the desired speed") + fi +else +newmhz=$1 +fi +if [ $newmhz ]; then + if [ $newmhz -ge $safemhz ]; then + if [ $DISPLAY ]; then + answer=$(zenity --question --title "Alert" --text "You are trying to set the cpu clock to $newmhz which is above its specification of $safemhz, doing so may burn down your house, sour milk, or just blow up (ok, not that likely)! proceed?";echo $?) + echo $answer + if [ $answer = 1 ]; then exit 1; fi + else + answer="n";read -p "You are trying to set the cpu clock to $newmhz which is above its specification of $safemhz, doing so may burn down your house, sour milk, or just blow up (ok, not that likely)! proceed? [y/n]" -t 10 answer + echo $answer + if [ $answer = n ]; then exit 1; fi + fi + fi + + if [ $newmhz -le $minmhz ]; then newmhz=$minmhz; fi + if [ $newmhz -ge $maxmhz ]; then newmhz=$maxmhz; fi +fi +echo $newmhz > $device +echo cpu_mhz_max set to $(cat /proc/pandora/cpu_mhz_max) -- 2.39.2