Difference between revisions of "Pager Nagger"
Jump to navigation
Jump to search
Hopspitfire (talk | contribs) (New page: I use my phone as a pager when I'm on-call at work. The Pre's notification tone is //way// too short and quiet to wake me up. Here's a script that will nag you by playing a .wav file eve...) |
(removed inaccurate warning which was added based on false conclusions in troubleshooting) |
||
(18 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
− | I use my phone as a pager when I'm on-call at work. The Pre's notification tone is | + | I use my phone as a pager when I'm on-call at work. The Pre's notification tone is ''way'' too short and quiet to wake me up. Here's a script that will nag you by playing a .wav file every minute while you have unread messages. The latest version also vibrates and blinks the LEDs. |
== Prerequisites== | == Prerequisites== | ||
− | * Root access | + | * [[Portal:Accessing_Linux | Root access]] |
− | * | + | * [[Crond | Crond enabled]] |
== Script code== | == Script code== | ||
Line 12: | Line 12: | ||
SOUND=/media/internal/ringtones/pager.wav | SOUND=/media/internal/ringtones/pager.wav | ||
+ | LIGHT=1 | ||
+ | BUZZ=1 | ||
check() { | check() { | ||
Line 24: | Line 26: | ||
x=0 | x=0 | ||
until [ "$x" = 4 ] ; do | until [ "$x" = 4 ] ; do | ||
− | aplay -q "$SOUND" | + | aplay -q "$SOUND" & |
− | sleep 60 | + | y=1 |
− | + | if [ "$BUZZ" = 1 ] ; then | |
− | + | /usr/bin/luna-send -n 1 palm://com.palm.vibrate/vibrate {\"period\":1,\"duration\":1000\} > /dev/null 2>&1 | |
− | + | z=10 | |
− | + | else | |
− | + | z=12 | |
− | + | fi | |
+ | if [ "$LIGHT" = 1 ] ; then | ||
+ | until [ "$y" = "$z" ] ; do | ||
+ | sleep 1 | ||
+ | echo 00 >/sys/class/leds/core_navi_left/brightness | ||
+ | echo 100 >/sys/class/leds/core_navi_center/brightness | ||
+ | echo 00 >/sys/class/leds/core_navi_right/brightness | ||
+ | sleep 1 | ||
+ | echo 80 >/sys/class/leds/core_navi_left/brightness | ||
+ | echo 00 >/sys/class/leds/core_navi_center/brightness | ||
+ | echo 80 >/sys/class/leds/core_navi_right/brightness | ||
+ | sleep 1 | ||
+ | echo 00 >/sys/class/leds/core_navi_left/brightness | ||
+ | echo 60 >/sys/class/leds/core_navi_center/brightness | ||
+ | echo 00 >/sys/class/leds/core_navi_right/brightness | ||
+ | sleep 1 | ||
+ | echo 40 >/sys/class/leds/core_navi_left/brightness | ||
+ | echo 00 >/sys/class/leds/core_navi_center/brightness | ||
+ | echo 40 >/sys/class/leds/core_navi_right/brightness | ||
+ | sleep 1 | ||
+ | echo 00 >/sys/class/leds/core_navi_left/brightness | ||
+ | echo 00 >/sys/class/leds/core_navi_center/brightness | ||
+ | echo 00 >/sys/class/leds/core_navi_right/brightness | ||
+ | check | ||
+ | if [ "$?" = 1 ] ; then | ||
+ | y=$((y+1)) | ||
+ | else | ||
+ | exit 0 | ||
+ | fi | ||
+ | done | ||
+ | x=$((x + 1)) | ||
+ | else | ||
+ | sleep 60 | ||
+ | check | ||
+ | if [ "$?" = 1 ] ; then | ||
+ | x=$((x + 1)) | ||
+ | else | ||
+ | exit 0 | ||
+ | fi | ||
+ | fi | ||
+ | |||
done | done | ||
} | } | ||
Line 62: | Line 104: | ||
== To Do/Bugs== | == To Do/Bugs== | ||
− | As the message is marked read in the database when it is closed, the sound will continue to play every minute until the messaging app is closed (or until that chat card is closed if you've done the | + | As the message is marked read in the database when it is closed, the sound will continue to play every minute until the messaging app is closed (or until that chat card is closed if you've done the [[stock-application-mods |Create a new card for each conversation]] mod). |
− | + | == Acknowledgments== | |
− | + | Thanks to Sargun for the [[tracking | tracking script]] which inspired the layout of the code, as well as started me looking at the databases. | |
− | + | This is great thanks!! |
Latest revision as of 03:18, 3 September 2009
I use my phone as a pager when I'm on-call at work. The Pre's notification tone is way too short and quiet to wake me up. Here's a script that will nag you by playing a .wav file every minute while you have unread messages. The latest version also vibrates and blinks the LEDs.
Prerequisites
Script code
#!/bin/sh SOUND=/media/internal/ringtones/pager.wav LIGHT=1 BUZZ=1 check() { cmd='SELECT summary FROM com_palm_messaging_data_ChatThread WHERE unreadCount > 0 AND type = "SMS" AND summary != "";' output=$(echo $cmd|sqlite3 /var/luna/data/dbdata/PalmDatabase.db3 2> /dev/null) || return 0 if [ -n "$output" ] ; then return 1 fi } play() { x=0 until [ "$x" = 4 ] ; do aplay -q "$SOUND" & y=1 if [ "$BUZZ" = 1 ] ; then /usr/bin/luna-send -n 1 palm://com.palm.vibrate/vibrate {\"period\":1,\"duration\":1000\} > /dev/null 2>&1 z=10 else z=12 fi if [ "$LIGHT" = 1 ] ; then until [ "$y" = "$z" ] ; do sleep 1 echo 00 >/sys/class/leds/core_navi_left/brightness echo 100 >/sys/class/leds/core_navi_center/brightness echo 00 >/sys/class/leds/core_navi_right/brightness sleep 1 echo 80 >/sys/class/leds/core_navi_left/brightness echo 00 >/sys/class/leds/core_navi_center/brightness echo 80 >/sys/class/leds/core_navi_right/brightness sleep 1 echo 00 >/sys/class/leds/core_navi_left/brightness echo 60 >/sys/class/leds/core_navi_center/brightness echo 00 >/sys/class/leds/core_navi_right/brightness sleep 1 echo 40 >/sys/class/leds/core_navi_left/brightness echo 00 >/sys/class/leds/core_navi_center/brightness echo 40 >/sys/class/leds/core_navi_right/brightness sleep 1 echo 00 >/sys/class/leds/core_navi_left/brightness echo 00 >/sys/class/leds/core_navi_center/brightness echo 00 >/sys/class/leds/core_navi_right/brightness check if [ "$?" = 1 ] ; then y=$((y+1)) else exit 0 fi done x=$((x + 1)) else sleep 60 check if [ "$?" = 1 ] ; then x=$((x + 1)) else exit 0 fi fi done } if [ ! -f "$SOUND" ] ; then SOUND=/usr/palm/sounds/alert.wav fi check || play
Installation
- Copy a .wav file to /media/internal/ringtones/pager.wav (or to the ringtones directory in USB mode).
mkdir -p /opt/scripts
- Copy the script to /opt/scripts/pager.
chmod +x /opt/scripts/pager rootfs_open -w
- Add the following line to /etc/cron/crontabs/root:
*/5 * * * * /opt/scripts/pager
Remember to copy a .wav file to /media/internal/ringtones/pager.wav.
To Do/Bugs
As the message is marked read in the database when it is closed, the sound will continue to play every minute until the messaging app is closed (or until that chat card is closed if you've done the Create a new card for each conversation mod).
Acknowledgments
Thanks to Sargun for the tracking script which inspired the layout of the code, as well as started me looking at the databases.
This is great thanks!!