Difference between revisions of "Pager Nagger"

From WebOS Internals
Jump to: navigation, search
(toned down warning due to jettero reply / mitigation)
(removed inaccurate warning which was added based on false conclusions in troubleshooting)
 
Line 1: Line 1:
<b>Warning</b>
 
 
Sqlite is designed for one user per database.  Accessing PalmDatabase.db3 in sqlite3 while Luna is running will eventually create a conflict where the sqlite3 binary has the database locked at the same time as Luna tries to access it.  It was thought that this same technique caused a crash possibly resulting in damage to PalmDatabase.db3.  Members of the community are currently investigating a better solution that works using the standard webOS application / service architecture.  --destinal
 
 
 
<b>Re: warning</b>
 
 
I'm not entirely convinced the crash related to the nagger.  My nagger is/was a daemon written in C that did pretty much the exact same thing as the shellscript (but also checked the email address of the 6245 SMS).  I have attached a crashlog to [[JetsSelfInflictedWipeCrash | this page]].  --jettero
 
 
== Original Document HEAD ==
 
 
 
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.
 
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.
  

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

  1. Copy a .wav file to /media/internal/ringtones/pager.wav (or to the ringtones directory in USB mode).
mkdir -p /opt/scripts
  1. Copy the script to /opt/scripts/pager.
chmod +x /opt/scripts/pager
rootfs_open -w
  1. 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!!