Modifying Stock Applications

From WebOS Internals
Jump to navigation Jump to search
Warning: This page baddly needs reorganization. It should be split up into the individual mods on individual pages and added into Portal:Patches to webOS as individual mods. Eventually this page will become Deprecated.


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 access to linux on 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.





PDF Viewer


Email App



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 (accessing linux, 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