Modifying Stock Applications

From WebOS Internals
Jump to navigation Jump to search

This section includes instructions for modifying the stock WebOS applications to add potentially useful capabilities...and/or remove annoyances. In general, the procedures listed here will normally require you to do the following:

  • Gain root access to your device.
  • Remount the file system as read/write: rootfs_open -w
  • Edit HTML, CSS, and/or JavaScript files by following one or more of the tutorials below.
  • Return the system to read-only state: mount -o remount,ro /

Standard caveats apply. If you aren't careful, you may render an application and/or your device non-functional. That said, if you are careful and ensure that you backup each file before you modify it, you should be fine. Worst case, you should be able to roll your changes back and fix any damage that you have done. Thus, we suggest backing up each file on the device before your initial edit. For example, for a file named some_file.js, first execute:

cp -ip some_file.js some_file.bak

Here is a "quick and dirty" backup script that you might want to use if you find yourself making a lot of changes. 1: At the # prompt, vi /opt/bin/backup 2: copy and paste this code:

#!/bin/sh
# This file backups whatever file is called as parameter to the user's home
# dir and adds a timestamp.
# AUTHOR:      firestorm_v1
# Modified by: JackieRipper

if [ -z "$1" ] ; then
	echo "You must specify the file to be copied."
	exit 1
fi

datestamp=$(date +%m%d%y)
source="$1"
destdir="${2:-${HOME}}"
srcname="$(echo "$source" | sed 's|/|_|g')"
dest="${destdir}/${srcname}-backup-${datestamp}"
x=0
until [ ! -f "$dest" ] ; do
#until [ ! -f "$dest" -a ! -d "$dest" ] ; do
	x=$((x + 1))
	dest="${destdir}/${srcname}-backup-${datestamp}.${x}"
done
cp -p "$source" "$dest"
#cp -rp "$source" "$dest"
echo "Backed up $source to $dest"

3: Save and quit VI (Esc, : w q )

4: Give the script execute permissions: chmod +x /opt/bin/backup

Usage: When you want to modify something but want to back it up, run the script with the file (or directory if using the commented version of the until and cp lines) to be backed up as an argument, and optionally a destination folder as a second argument. Though not necessary, it's best to provide the full path to the file to be backed up, so you can easily determine where the backup came from should you need to restore. The slashes will be converted to underscores.

root@castle:/opt/bin# cd /usr/palm/applications/com.palm.app.clock/app/views/ring/
root@castle:/usr/palm/applications/com.palm.app.clock/app/views/ring# ls
ring-scene.html
root@castle:/usr/palm/applications/com.palm.app.clock/app/views/ring# backup /usr/palm/applications/com.palm.app.clock/app/views/ring/ring-scene.html
Backed up /usr/palm/applications/com.palm.app.clock/app/views/ring/ring-scene.html to /var/home/firestorm   (Note, your user's name will show here)

This will save the file you added as a parameter (in this case ring-scheme.html) to your non-root user's home directory (/home/your_username) with today's datestamp on it. It you specified the full path, the slashes will be converted to underscores. If you back up a file more than once, a digit will be appended to the date stamp.

root@castle:/var/home/firestorm# ls
_usr_palm_applications_com.palm.app.clock_app_views_ring_ring-scene.html-backup-062309  pidof-backup-062309
chatview-assistant.js-backup                                                            pidof-backup-062309.1
chatview-assistant.js-backup-062309.1                                                   pidof-backup-062309.2
listview-assistant.js-backup-062309                                                     securityconfig-assistant.js-backup-062309

You then have a dated version to which you can roll back if your changes cause problems with the application.

If you use this backup script (works for file or directory version but ONLY for full path backups) then this corresponding restore script will restore any backup supplied as argument to it's original location (if it is a directory you'll lose ANY changes in the directory more recent than the backup).

#!/bin/sh

# This file restores whatever file is called as parameter
# IF IT WAS backed up with corresponding backup script by firestorm_v1 and JackieRipper
# See: http://predev.wikidot.com/stock-application-mods
# Only works for files backed up using full path (looks for /_ in restore file)
# you have to give a path to the restore file that incluse at least one dir (./ will work)
# and make sure there're no other '/_' in the path
# Also, make sure the are no '_' in the backup directory
# or in the file/directory backed up/to be restored

# Author: Merlin - based on backup

if [ -z "$1" ] ; then
    echo "You must specify the file to be restored."
    exit 1
fi

backup="$1"
restore="$(echo "$backup" | sed 's|.*/_|_|')"

if [ "$restore" = "$backup" ] ; then
    echo "restore only works for files backed up using full path"
    exit 1
fi
restore="$(echo "$restore" | sed 's|_|/|g')"
restore="$(echo "$restore" | sed 's|-backup-.*||')"
rm -rf "$restore"
cp -frp "$backup" "$restore"
echo "Restored $backup to $restore"

Usage:

root@castle:/var/home/root# backup /usr/palm/applications/com.palm.app.ondevicedemo/app
Backed up /usr/palm/applications/com.palm.app.ondevicedemo/app to /home/merlin/backup/_usr_palm_applications_com.palm.app.ondevicedemo_app-backup-20090715
root@castle:/var/home/root# ls -l /usr/palm/applications/com.palm.app.ondevicedemo/app/models/
-rw-r--r--    1 root     root         2937 Jun 16 21:51 podd-video.js
root@castle:/var/home/root# rm /usr/palm/applications/com.palm.app.ondevicedemo/app/models/podd-video.js
root@castle:/var/home/root# restore /home/merlin/backup/_usr_palm_applications_com.palm.app.ondevicedemo_app-backup-2009
0715
Restored /home/merlin/backup/_usr_palm_applications_com.palm.app.ondevicedemo_app-backup-20090715 to /usr/palm/applications/com.palm.app.ondevicedemo/app
root@castle:/var/home/root# ls -l /usr/palm/applications/com.palm.app.ondevicedemo/app/models/
-rw-r--r--    1 root     root         2937 Jun 16 21:51 podd-video.js

Alternatively, if you'd like to keep the original app in your launcher, see this method for copying the entire app as a new app before you begin making mods.

Modify stock app while keeping original in Launcher

Okay, here's the good stuff.


Changing Alarm Clock Button Order and Snooze Duration

First we change the button order. The file containing the look of the alarm alert is /usr/palm/applications/com.palm.app.clock/app/views/ring/ring-scene.html

Simply swap lines 15 and 16 to put the snooze button on top.


Second we will change the alarm duration. It is located at lines 379 and 381 of /usr/palm/applications/com.palm.app.clock/app/models/alarm.js


The default times are below :

Alarm.kAlarmSnoozeDuration = "00:05:00";
Alarm.kAlarmSnoozeInterruptedDuration = "00:05:00";

Reboot That's all! Thanks to user optik678 for the alarm clock modification.

Camera Application

Download Amazon Music over EVDO

The Amazon app only allows downloading songs over WiFi. This will also allow downloading songs over EVDO/3G.

cd /usr/palm/applications/com.palm.app.amazonstore/app/models cp download-manager.js download-manger.js.sav

Update: Fix for Pre 1.1.0 Amazon over EvDo

To "comment out" a line, add // at the beginning. Example:

printf("This is code");
//printf("This is commented out");

edit download-manager.js

comment out lines 440-442

440:  //if (userInitiated &&....
441:          //this.showWifiRequired....
442:  //}

then force lines 465 & 466 to be true and comment out line 467

465:  if (1 == 1) {
466:     if ( 1 == 1) 
467: 		 //|| PalmSystem.version.index....

reboot (or orange-sym-r)

Credit for 1.1.0 amazon over EvDo(3G) fix: Jack87


Bellow only works prior to the 1.1.0 update

Comment out lines 416-423 (if condition stating songs must be downloaded via wifi)
Force lines 446 and 447 to be always true.... if ( 1 == 1 )
446:  if (1 == 1) {
447:      if (1 == 1)
Comment out line 448 (test for "desktop")
Confirm you have appropriate matching parens and brackets

reboot  (or orange-sym-r)


Discuss this mod on Pre Central

See how to modify the app while keeping the original in Launcher

It took about 30 seconds to download a 3 minute song over EVDO with speedtest showing about 1Mbps or so, but hard to say as speed was bursting up to 2Mbps and down to 1Mbps for each test.

Modify-stock-app.jpg Modify-stock-app2.jpg

Credit

xorg, Jack87

Messaging Application

Character Counter

Google Talk (GTalk) Force Send when User Offline

The "Adding Timestamps" and "New Card" code has been moved to the new wiki on the messaging-mods page.

collapsible show="+ Show" hide="- Hide" hideLocation="both"

Adding Timestamps to All Received Messages

Introduction

A number of users have requested adding timestamps to each message that arrives on the device. Palm actually goes out of their way to group messages that have arrived during various time intervals, but if you'd prefer to see a timestamp on each message, simply follow the instructions below.

Procedure

  1. Gain root access to your device
  1. Remount the file system as read/write
  1. cd to /usr/palm/applications/com.palm.app.messaging/app/controllers/
  1. Backup chatview-assistant.js (just to be safe)
  1. Open chatview-assistant.js and comment out the following lines:
* 1169 - line that starts with: if(!ChatFlags.
* 1177 - line that starts with: if(today-msg.
* 1179 - first closing bracket on its own line: }
* 1180 - second closing bracket on its own line: }
  1. Save the file and exit the editor
  1. Remount the file system as read-only
  1. Logout of your root session
  1. Reboot the device

You should now see a full timestamp on all received messages.


Acknowledgements

Thanks to user tk102 and user scuba_steve on PreCentral for the mod.


Make the messaging app create a new card for each conversation

Introduction

The message app can be a pain when you have multiple conversations going on. You often have to swipe back and then pick someone else.

It gets annoying fast. This modification modifies the messaging application so that a new card is created whenever you click into a conversation.

Procedure

Edit /usr/palm/applications/com.palm.app.messaging/app/controllers/listview-assistant.js and replace the launchChatView function with the following function:

launchChatView: function(chatThreadId) {
    //Need to jump to that stage if it exists
    var stageController = Mojo.Controller.appController.getStageController("messaging"+chatThreadId);
        if (stageController) {
            stageController.activate();
            return;
        }

    var params = {name: 'messaging' + chatThreadId,
            lightweight: Mojo.Controller.appInfo.lwStages
    };

    var callback = function(controller) {
        controller.pushScene('chatview',chatThreadId,{
                    focusWindow: true
                });        
    };

    Mojo.Controller.getAppController().createStageWithCallback(params, callback); //doesnt create ifit exists sooo
  },

  clearListBadgeForChatThreadId: function(chatThreadId) {
    var badgeContainers = ["buddyBageContainer","historyBageContainer"];
    var listItem;
    for (var i = 0; i < badgeContainers.length; i++) {
        listItem = this.controller.get(badgeContainers[i] + chatThreadId);
        if (listItem && !listItem.hasClassName('hide-unread-count')) {
            listItem.addClassName('hide-unread-count');
        }
    }    
  },

  

Now in /usr/palm/applications/com.palm.app.messaging/app/controllers/chatview-assistant.js, comment out lines 246 and 247.

This change will ensure that if you use the "back gesture" in a chat, the application doesn't bring you back to the conversation list...or do anything else.

To "comment out" a line, add // at the beginning. Example:

printf("This is code");
//printf("This is commented out");

Concerns

There is some delay in creating the new cards. I'm not sure why though.

As stated above, the cards are only opened when you click into the conversation. Responding to a notification will result in the reuse of the buddy list window, and you have disabled the back gesture.

Acknolwedgements

Thanks to mikedg for the mod.

chris_phelps is continuing to work on this modification to get it working more completely.

The first step is to clean up the other launchChatNNN functionality in app-assistant.js which accepts Luna System calls from the notification dashboard items which are created when a new message is received on the phone. These code modifications are being tested currently, and will be posted when we figure out how to clear the new message counters in the main listview-assistant.js. /collapsible


PDF Viewer


Email App


Dialer / Phone App

Turning off Dialpad Noise

Introduction

When dialing on the phone with sound enabled, the phone makes really really loud noises. There are a number of ways to address this. One's first attempt might be to lower the volume on the DTMF mp3s. However, a quick examination of the phone app indicates that these same sounds are played over the phone for touch-tone responsive systems, so mucking with them is not a good idea.

The Change

The key is the TelephoneyCommands.sendDTMF function. It sends a tone over the network, or optionally, just a noise on the speaker (if the second argument is true: it's mapped to a service parameter called "feedBackOnly". In dialpad assistant, simply commenting out these

lines stops the noise. This dialpad assistant is by default located in

/usr/palm/applications/com.palm.app.phone/app/controllers/dialpad-assistant.js.

The lines of interest in dialpad-assistant.js are:

Line 509 for the touch screen.

Line 791 for the keyboard keys.

Comment out one or both, as desired.

To "comment out" a line, add // at the beginning. Example:

printf("This is code");
//printf("This is commented out");

Acknowledgements

Thanks to icederror for the mod, writeup by jblebrun

--

Sounds and Alerts Control Panel

See the third section at the bottom of Notification Sounds

Screen and Lock Application

Keep phone from entering standy while in remote sessions.

Introduction

This modification is really simple but effective. if your using the SSH shell your phone screen turns off and kills the session since you can only change from 1 to 3 minutes. this modification allows you to add as many values as you desire. I included the changes to add "5 Minutes" and "Never" but more can be done by following the same template.

The Change

Look for the file securityconfig-assistant.js in /usr/share/palm/application/com.palm.app.screenlock/app/controllers and open it with the editor your most comfortable with. the line to look for is as follows.

Note: On newer versions (WebOS 1.0.3), this is in /usr/palm/applications/com.palm.app.screenlock/app/controllers

//Available Timer Values.
	availableTimers: [{label: $L('30 seconds'), value:30},{label: $L('1 minute'), value:60},{label: $L('2 minutes'), value:120},{label: $L('3 minutes'), value:180}],

Change to:

//Available Timer Values.
	availableTimers: [{label: $L('30 seconds'), value:30},{label: $L('1 minute'), value:60},{label: $L('2 minutes'), value:120},{label: $L('3 minutes'), value:180},{label: $L('5 minutes'), value:300},{label: $L('Never'), value:10800}],

NOTE: The time is listed in their under seconds and "Never" is actually 3 hours as not to kill battery life should you forget you set it to never and left your screen on as i've done a few times myself. you can set this value or add more values very easily and the listbox will allow scrolling.

Acknowledgements

Thanks to BinaryTechZone for the modification.


Sudoku!

Introduction

I hated the zoom-in / zoom-out feature of the Sudoku game, so here simple fix to make it so there is no zooming. Instead you just click on the square and click the number to be in that square.

Procedure

  1. Standard stuff (rooting, make system read/write, making a backup, etc)
  1. Open /var/usr/palm/applications/com.cakefight.sudoku/app/assistants/first-assistant.js and comment out the following line:
* 67 - line that starts with: Mojo.listen(this.controller.get('sudokuscroller')...
  1. Standard finish stuff (save it, put system back into read-only, etc)

No need to reboot. The game will now just put the focus in whatever square you clicked, instead of having to click once to zoom in, and a second time to pick the square and zoom out. Other than that, it works just the same.

Credit

lyht


mCraig

Enabling the "Personals" category

By default, the Personals category and some other adult-themed services are hidden from the mCraig app. We can enable them simply by uncommenting a few lines, and adding a few others.

Modify-stock-app3.jpg

Procedure

SSH in to rooted Pre

Mount filesystem as r/w, navigate to mCraig folder and create a backup of current database.js

mount -o remount,rw /
cd /var/usr/palm/applications/com.splashdata.app.mcraig
cp database.js database.js.bak

Edit database.js

vi database.js

line 12, find:

	{ "file":"subcatshousing", "name":"Housing", }, 

and add above:

	{ "file":"subcatspersonals", "name":"Personals", }, 

Uncomment line 21 (now 22):

    { "name":"Personals", "file":"subcatspersonals"},

Uncomment line 210 (now 211):

    { "dir":"adg", "fullname":"gigs > adult", "name":"adult", "subcat":"True",  }, 

line 262-271 (now 263-272) find:

subcatspersonals: [  { "dir":"stp", "name":"strictly platonic",  }, 
    { "dir":"w4w", "name":"women seek women",  }, 
    { "dir":"w4m", "name":"women seeking men",  }, 
    { "dir":"m4w", "name":"men seeking women",  }, 
    { "dir":"m4m", "name":"men seeking men",  }, 
    { "dir":"msr", "name":"misc romance",  }, 
    { "dir":"cas", "name":"casual encounters",  }, 
    { "dir":"mis", "name":"missed connections",  }, 
    { "dir":"rnr", "name":"rants and raves",  }, 
    ], 

and replace with:

subcatspersonals: [ 
    { "dir":"ppp", "name":"all personals",  }, 
    { "dir":"stp", "name":"strictly platonic", "subcat":"True",  }, 
    { "dir":"w4w", "name":"women seek women", "subcat":"True",  }, 
    { "dir":"w4m", "name":"women seeking men", "subcat":"True",  }, 
    { "dir":"m4w", "name":"men seeking women", "subcat":"True",  }, 
    { "dir":"m4m", "name":"men seeking men", "subcat":"True",  }, 
    { "dir":"msr", "name":"misc romance", "subcat":"True",  }, 
    { "dir":"cas", "name":"casual encounters", "subcat":"True",  }, 
    { "dir":"mis", "name":"missed connections", "subcat":"True",  }, 
    { "dir":"rnr", "name":"rants and raves", "subcat":"True",  }, 
    ],

Uncomment line 279 (now 280):

    { "dir":"ers", "fullname":"services > erotic", "name":"erotic", "subcat":"True",  }, 

Write changes & quit vi, mount filesystem as r/o

:wq
mount -o remount,ro /

No need to reboot, simply restart the mCraig app and test out your new categories!

Credit

r3compile + BigMatza


Bookmarks in MediaPlayer

Adds a bookmark when leaving a song so you can skip to the bookmark when you come back.


+ Tasks Application

Tasks-details.png

Always Show Details of New Tasks

Introduction

A small modification that changes how new tasks are handled. When you create a new task, it will show the details window for that task immediately, allowing you to easily set the task name, priority, list and due date.

More Details

http://predev.wikidot.com/always-show-new-task-details


Photos Slideshow

Adds a button to full screen photo to allow automatic movement another photo. http://predev.wikidot.com/photos-slideshow


Skipping Tracks in Media Player Using Volume Up/Down Buttons

Add the ability to skip to next/prev track by holding down the volume keys. track-skipping-using-volume-up-down-buttons


Clock Modifications

Enabling the hidden theme

This is a theme that Palm doesn't have activate as of webOS1.0.4

In: /usr/palm/applications/com.palm.app.clock/themes/ File: themes.json @ Line 13 replace

}

with

},
{
		"name":"manualanalog",
		"nicename":"Analog Black",
		"description":"",
		"source": "themes/manualanalog/"
}

Restart LunaSysMgr

sudo ./sbin/initctl stop LunaSysMgr
sudo ./sbin/initctl start LunaSysMgr

Thanks goes out to frankos72 @ precentral for this orginal modification.


Enable Day & Date within the new clock

This mod will give you the Time & Date on the new theme Analog Black Clock mod1.jpg

In: /usr/palm/applications/com.palm.app.clock/themes/manualanalog/

File: manualanalog-clock-functions.js

@ Line: 92&93 un-comment the lines so they look like this:

                       
 this.controller.get('date').textContent = Mojo.Format.formatDate(now, {"date":"short"});
 this.controller.get('day').textContent = Mojo.Format.getDateTimeHash().medium.day[now.getDay()];

In: /usr/palm/applications/com.palm.app.clock/themes/manualanalog/ File: manualanalog-clock.html

@ Line: 4&5 make it look like this:

     <div id="day" class="day"></div>
     <div id="date" class="date"></div>

Restart LunaSysMgr, enjoy.

sudo ./sbin/initctl stop LunaSysMgr
sudo ./sbin/initctl start LunaSysMgr
-Phrozen