webOS Nation Forums >  webOS apps and software >  webOS development > Tweak: Turn on LED when text message is received
Tweak: Turn on LED when text message is received

  Reply
 
LinkBack Thread Tools Display Modes
Old 07/06/2009, 06:38 PM   #1 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default Tweak: Turn on LED when text message is received

One of the features I liked on my old Treo was the blinking green LED when I had a waiting text message. There's no such functionality out of the box for the Pre.

With this change, however, the center button LED will illuminate when you have a waiting text message!

As a prerequisite, you'll need the webosinternals services installed so you can run shell commands from within your application. If you already have this installed (for the my-tether application, for example) you can skip this step.

As root:

Code:
cd /tmp/
mount -o remount,rw /

wget http://gitorious.org/webos-internals/applications/blobs/raw/db385edfa3f71ceb98401c16dd94b2490bfaaae5/org.webosinternals.services/org.webosinternals.services-0.4_all.ipk
ipkg install org.webosinternals.services-0.4_all.ipk
rm org.webosinternals.services-0.4_all.ipk
Next we'll create the script to turn on the LED:

Code:
cd /usr/palm/applications/com.palm.app.messaging/app/
mkdir scripts
cd scripts
In vi or your editor of choice, create the file led_on.sh in the scripts directory:

Code:
#!/bin/sh
sleep 9
echo 100 >/sys/class/leds/core_navi_center/brightness
While still in the scripts directory, change the permissions on the file:

Code:
chmod 744 led_on.sh
Now we need to tie our script into the messaging application:

Code:
cd /usr/palm/applications/com.palm.app.messaging/app/controllers
Apply the following patch:

Code:
--- notification-assistant.js.bak       Mon Jul  6 14:04:10 2009
+++ notification-assistant.js   Mon Jul  6 18:48:17 2009
@@ -189,7 +189,15 @@
        var dashboard = this.controller.getStageController(DashboardMessageStageName);

        if (dashboard) {
+               var displayOn = this.Messaging.DisplayState.isDisplayOn();
                dashboard.delegateToSceneAssistant("update");
+               if (!displayOn) {
+                       this.controller.serviceRequest('palm://org.webosinternals.shell', {
+                               method: 'runCmd',
+                               parameters: {
+                                       cmd: '/usr/palm/applications/com.palm.app.messaging/app/scripts/led_on.sh'}
+                       });
+               }
        } else {
                // Create a dashboard
                var f = function(stageController){
@@ -214,9 +222,13 @@
                                this.isNewMessageDashboardPending = true;
                                createDashboard.delay(5);
                        }
-
                } else {
                        createDashboard(); // if the screen is off, create the dashboard right away
+                       this.controller.serviceRequest('palm://org.webosinternals.shell', {
+                               method: 'runCmd',
+                               parameters: {
+                                       cmd: '/usr/palm/applications/com.palm.app.messaging/app/scripts/led_on.sh'}
+                       });
                }
        }
 };
Now lock up the filesystem and reboot:

Code:
mount -o remount,ro /
/sbin/reboot
More testing and feedback would be appreciated. Only got this working this evening and there may be an unintended side effect or two, but hopefully not <knock on wood>.

Last edited by Keegan99; 07/07/2009 at 10:57 AM.
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 07:33 PM   #2 (permalink)
Member
 
as4life's Avatar
 
Join Date: Feb 2007
Posts: 581
Likes Received: 0
Thanks: 30
Thanked 46 Times in 35 Posts
Default

i will definitely try this Thanks!
as4life is offline   Reply With Quote
Old 07/06/2009, 07:40 PM   #3 (permalink)
Member
 
Join Date: Dec 2008
Posts: 51
Likes Received: 0
Thanks: 5
Thanked 7 Times in 5 Posts
Default

ok... so how do i apply the patch? do i just mod the notification-assistant.js if so where does this code fit in? Thanks
lordelfkin is offline   Reply With Quote
Thanked By: unique54
Old 07/06/2009, 07:46 PM   #4 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default

You can either decode it by hand and edit the source file manually (It's basically inserting two small blocks of code into the original notification-assistant.js) or you can grab and use the patch utility:

Code:
ipkg-opt install patch
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 07:50 PM   #5 (permalink)
Member
 
Join Date: Apr 2003
Posts: 43
Likes Received: 0
Thanks: 11
Thanked 21 Times in 9 Posts
Default

how do you use patch once you install it?

Last edited by tozfeekum; 07/06/2009 at 08:01 PM.
tozfeekum is offline   Reply With Quote
Thanked By: abejenaru73
Old 07/06/2009, 08:04 PM   #6 (permalink)
Member
 
Eguy's Avatar
 
Join Date: Apr 2007
Location: City of Angels
Posts: 2,533
Likes Received: 0
Thanks: 371
Thanked 175 Times in 132 Posts
Default

This is great! Is there a way we can have it pulse twice for a new email, 3 times for a missed call, etc?
__________________
Palm History: Palm III>IIIc>CLIÉ NR70v>CLIÉ TG50>Tungsten C>Treo 650>Treo 700p>Centro>Pre!! 6/5/09
Phone History: Way too long

Sorry Timmy, SERO does not work with the Pre.
If you have an iTouch click me.
Eguy is offline   Reply With Quote
Old 07/06/2009, 08:51 PM   #7 (permalink)
Member
 
Join Date: Dec 2008
Posts: 51
Likes Received: 0
Thanks: 5
Thanked 7 Times in 5 Posts
Default

when installing the patch i get

Quote:
patching file notification-assistant.js
patch: **** malformed patch at line 11: + method: 'runCmd',
?? not sure what i did, simply copied the patch code and created a file with it..

Last edited by lordelfkin; 07/06/2009 at 08:58 PM.
lordelfkin is offline   Reply With Quote
Old 07/06/2009, 08:52 PM   #8 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default

Pulsing would be a bit of a challenge, as it would require a continuously running script changing the value of the LED intensity. Without the ability to more cleanly kick off and terminate background processes (or a robust LED API) I don't see a way to do it.
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 08:58 PM   #9 (permalink)
Member
 
Join Date: Dec 2008
Posts: 51
Likes Received: 0
Thanks: 5
Thanked 7 Times in 5 Posts
Default

Quote:
Originally Posted by tozfeekum View Post
how do you use patch once you install it?
"patch --help" will give you the syntax and how to use
lordelfkin is offline   Reply With Quote
Old 07/06/2009, 09:01 PM   #10 (permalink)
Member
 
as4life's Avatar
 
Join Date: Feb 2007
Posts: 581
Likes Received: 0
Thanks: 30
Thanked 46 Times in 35 Posts
Default

how do u exactly install the patch? i tried going on the pre wiki page but its down.
as4life is offline   Reply With Quote
Old 07/06/2009, 09:42 PM   #11 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default

Ok, the copy and paste may have marred the patch file, so here's the attachment.

To run the patch, copy it to /usr/palm/applications/com.palm.app.messaging/app/controllers, then:

Code:
cd /usr/palm/applications/com.palm.app.messaging/app/controllers
patch -p0 -i notification-assistant.js.patch.txt
Attached Files
File Type: txt notification-assistant.js.patch.txt (1.1 KB, 262 views) Email Attachment
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 09:46 PM   #12 (permalink)
Member
 
Join Date: Sep 2007
Posts: 337
Likes Received: 0
Thanks: 4
Thanked 53 Times in 31 Posts
Default

Quote:
Originally Posted by Eguy View Post
This is great! Is there a way we can have it pulse twice for a new email, 3 times for a missed call, etc?

You you can just have the script sleep then go to a different state then sleep again and go back to 100
atlanta is offline   Reply With Quote
Old 07/06/2009, 09:54 PM   #13 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default

Quote:
You you can just have the script sleep then go to a different state then sleep again and go back to 100
That's a one time pulse, but my reading of what Eguy wanted was more of a continual 'heartbeat', for lack of a better term. A morse code of sorts.
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 09:59 PM   #14 (permalink)
Member
 
Eguy's Avatar
 
Join Date: Apr 2007
Location: City of Angels
Posts: 2,533
Likes Received: 0
Thanks: 371
Thanked 175 Times in 132 Posts
Default

Quote:
Originally Posted by Keegan99 View Post
That's a one time pulse, but my reading of what Eguy wanted was more of a continual 'heartbeat', for lack of a better term. A morse code of sorts.
Yes, so it keeps pulsing untill you clear the notification .


Just an FYI:


Code:
root@castle:/usr/palm/applications/com.palm.app.messaging/app/controllers# patch
 -p0 -i notification-assistant.js.patch.txt
patching file notification-assistant.js
Hunk #1 succeeded at 333 with fuzz 1 (offset 144 lines).
Hunk #2 FAILED at 366.
1 out of 2 hunks FAILED -- saving rejects to file notification-assistant.js.rej
__________________
Palm History: Palm III>IIIc>CLIÉ NR70v>CLIÉ TG50>Tungsten C>Treo 650>Treo 700p>Centro>Pre!! 6/5/09
Phone History: Way too long

Sorry Timmy, SERO does not work with the Pre.
If you have an iTouch click me.
Eguy is offline   Reply With Quote
Old 07/06/2009, 10:08 PM   #15 (permalink)
Member
 
Join Date: Sep 2007
Posts: 337
Likes Received: 0
Thanks: 4
Thanked 53 Times in 31 Posts
Default

Opps put it in a while statement to create a pulse effect.
atlanta is offline   Reply With Quote
Old 07/06/2009, 10:12 PM   #16 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default

Quote:
Originally Posted by atlanta View Post
Opps put it in a while statement to create a pulse effect.
The problem there is that there's no clean way to kill the process.
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 10:13 PM   #17 (permalink)
Member
 
Join Date: Jun 2009
Posts: 100
Likes Received: 1
Thanks: 10
Thanked 40 Times in 13 Posts
Default

Quote:
root@castle:/usr/palm/applications/com.palm.app.messaging/app/controllers# patch
-p0 -i notification-assistant.js.patch.txt
patching file notification-assistant.js
Hunk #1 succeeded at 333 with fuzz 1 (offset 144 lines).
Hunk #2 FAILED at 366.
1 out of 2 hunks FAILED -- saving rejects to file notification-assistant.js.rej
Very strange. The lines being patched should be in the low 200's, not the mid to high 300's. Have you modified notification-assistant.js for something else previously?
Keegan99 is offline   Reply With Quote
Old 07/06/2009, 10:15 PM   #18 (permalink)
Member
 
Eguy's Avatar
 
Join Date: Apr 2007
Location: City of Angels
Posts: 2,533
Likes Received: 0
Thanks: 371
Thanked 175 Times in 132 Posts
Default

Nope, but just noticed it was wiped clean somehow and so was my backup, just copied a fresh js from the webos doctor and it worked.
__________________
Palm History: Palm III>IIIc>CLIÉ NR70v>CLIÉ TG50>Tungsten C>Treo 650>Treo 700p>Centro>Pre!! 6/5/09
Phone History: Way too long

Sorry Timmy, SERO does not work with the Pre.
If you have an iTouch click me.
Eguy is offline   Reply With Quote
Old 07/06/2009, 10:29 PM   #19 (permalink)
Member
 
Join Date: Jun 2009
Posts: 25
Likes Received: 0
Thanks: 0
Thanked 4 Times in 1 Post
Default

Your first command should be mount -o remount,rw /

not
mount -o remount rw, /
helfire is offline   Reply With Quote
Old 07/06/2009, 10:32 PM   #20 (permalink)
Member
 
mdmogren's Avatar
 
Join Date: Jun 2009
Posts: 519
Likes Received: 0
Thanks: 52
Thanked 65 Times in 43 Posts
Default

Quote:
Originally Posted by Keegan99 View Post
You can either decode it by hand and edit the source file manually (It's basically inserting two small blocks of code into the original notification-assistant.js) or you can grab and use the patch utility:

Code:
ipkg-opt install patch
Where is ipkg-opt located? I'm getting ipkg-opt not found?
mdmogren is offline   Reply With Quote
Thanked By: Croathlete
Reply

 

Thread Tools
Display Modes



 


Content Relevant URLs by vBSEO 3.6.0