Difference between revisions of "Pager Nagger"

From WebOS Internals
Jump to navigation Jump to search
Line 109: Line 109:
  
 
Thanks to Sargun for the [[tracking | tracking script]] which inspired the layout of the code, as well as started me looking at the databases.
 
Thanks to Sargun for the [[tracking | tracking script]] which inspired the layout of the code, as well as started me looking at the databases.
 +
 +
To get this to work for me I had to make my file say
 +
 +
 +
*/5 * * * * /opt/scripts/pager/pager.sh
 +
 +
 +
chmod 755 /opt/scripts/pager/pager.sh
 +
 +
This works fine until it goes to sleep. I don't have a touchstone and don't want to leave it on all the time. I need to find a work around. mamouton

Revision as of 04:16, 20 August 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.

To get this to work for me I had to make my file say


  • /5 * * * * /opt/scripts/pager/pager.sh


chmod 755 /opt/scripts/pager/pager.sh

This works fine until it goes to sleep. I don't have a touchstone and don't want to leave it on all the time. I need to find a work around. mamouton