Changes Alert/Notification Sounds

From WebOS Internals
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


This page details a way of making the Pre use a pre-defined MP3 from the USB storage side as it's Alert and Notification tones. This is a work around until Palm adds the UI to be able to modify these settings from the GUI.

Currently all of these methods still keep the Notification Tone as the sound used for new email, text, and charger connect. Seperating these is on the way.

You will need root shell access to perform these changes. Follow these instructions at your own risk. If you make an error (or perhaps even if you do it correctly) you risk bricking your phone, voiding your warranty, etc. These instructions assume a working knowledge of Unix/Linux command line. Also, note that these changes require rebooting the phone to take effect.

Simple Method (Overwrite notification.wav)

See Change the default notification.wav Sound.

SSH/USB Method

Copy two MP3's of your choice to the USB storage side of the Pre called 'notifications.mp3' and 'alerts.mp3'.

Warning: If you decide to put the mp3's into folders or use different names, you will need to modify the values in the sql 'update' statements below. Always escape the / path character like \/ as is shown in the code below. Failure to do so may result in inoperable notifications.

ssh -p 222 username@palm-pre
user@castle:~$ su -
root@castle:/home/root# cd /var/luna/preferences
root@castle:/var/luna/preferences# cp systemprefs.db systemprefs.db.bak
root@castle:/var/luna/preferences# sqlite3 systemprefs.db
sqlite> update Preferences set value='{ "fullPath": "\/media\/internal\/notifications.mp3", "name": "notifications.mp3" }' where key='notificationtone';
sqlite> update Preferences set value='{ "fullPath": "\/media\/internal\/alerts.mp3", "name": "alerts.mp3" }' where key='alerttone';
sqlite> .quit
root@castle:/var/luna/preferences# reboot

Once the Pre reboots, you should be able to hear your MP3s for Notifications and Alerts!

If you wish to change your tones, simply overwrite the MP3s as you desire.

Enjoy! LK

Question: Would putting these in a hidden folder prevent them showing up in the music player application? ~ natrixgli (steviebuns in IRC)

To hide the files, place a '.' in front of their names. To make changes later, you will need to enable hidden file view from your respective client.

The next two lines of code worked for me. ~ PreNomadBrad

update Preferences set value='{ "fullPath": "\/media\/internal\/.notifications.mp3", "name": "notifications.mp3" }' where key='notificationtone';
update Preferences set value='{ "fullPath": "\/media\/internal\/.alerts.mp3", "name": "alerts.mp3" }' where key='alerttone';

Sounds and Alerts Program Modification

Disclaimer: This is very involved and needs to be cleaned up. Use this method at your own risk until the code has been verified by others. Update: This process has been verified by linuxkidd.

This method involves editing three files in the com.palm.app.soundsandalerts directory. I am sure there are better ways to do this, however I have limited experience and did the best I could.

  • This mod has been turned into a stand alone application as well. Once it gets packaged up the link will be posted on precentral and this site. - Kaerey

Step One: Modify the Sounds and Alerts Program to add the new fields.

File needed: /usr/palm/applications/com.palm.app.soundsandalerts/app/views/soundsalertsconfig/soundsalertsconfig-scene.html

Between lines 50 and 51, add:

	<div id='currentalertrow' class="palm-row" x-mojo-tap-highlight="momentary">
				<div class="palm-row-wrapper">
					<div class="label" x-mojo-loc=''>Alert</div>
	            	<div id='currentalert' class="title"></div>					
	            </div>
             </div>
	<div id='currentnotificationrow' class="palm-row" x-mojo-tap-highlight="momentary">
				<div class="palm-row-wrapper">
					<div class="label" x-mojo-loc=''>Notification</div>
	            	<div id='currentnotification' class="title"></div>					
	            </div>
             </div>

Step 2:

File needed: /usr/palm/applications/com.palm.app.soundsandalerts/app/models/SystemService.js

Find the Section of Code that deals with getRingtone and setRingtone starting on line 9:

SystemService.setRingtone = function(value,callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"ringtone":value}, 			
		});
	return request;
}

SystemService.getRingtone = function(callback) {
	
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["ringtone"],"subscribe":true}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

We are going to create this section for Alerts and Notifications:

SystemService.getAlerts = function(callback) {
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["alerttone"]}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setAlerts = function(value){
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"alerttone":value}, 			
		});
	return request;
}

SystemService.getNotifications = function(callback) {
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'getPreferences',
			parameters: {"keys":["notificationtone"]}, 
			onSuccess: callback,
			onFailure: callback
		});
	return request;
}

SystemService.setNotifications = function(value){
	var request = new Mojo.Service.Request(SystemService.identifier, {
			method: 'setPreferences',
			parameters: {"notificationtone":value}, 			
		});
	return request;
}

Step 3:

File needed: /usr/palm/applications/com.palm.app.soundsandalerts/app/controllers/soundsalertsconfig-assistant.js

We will be creating handlers for Alerts and Notifications and Editing the handler for Ringtone in order to accomdate the new components.

At Line 81 you will see:

$('currentringtonerow').observe(Mojo.Event.tap, this.showAudioFilePicker.bindAsEventListener(this));

Notice that there is an extra line break where something may have been previously removed.

We need to create entries for Alert and Notification:

$('currentalertrow').observe(Mojo.Event.tap, this.showAlertFilePicker.bindAsEventListener(this));
$('currentnotificationrow').observe(Mojo.Event.tap, this.showNotificationFilePicker.bindAsEventListener(this));

Below that section you will see at line 84:

this.getCurrentVolumes();
this.getCurrentRingtone();
this.getVibrateSettings();	
this.getOtherSettings();

Add entries for Alerts and Notifications:

this.getCurrentAlert();
this.getCurrentNotification();

In the final step we need to create the handlers and edit the ringtone handlers.

Find the Code near line 215:

	getCurrentRingtone: function() {
		this.getCurrentRingtoneReq = SystemService.getRingtone(this.getCurrentRingtoneQuery.bind(this));
	},
	
	getCurrentRingtoneQuery: function(payload) {		
		if (payload.ringtone) {
			$('currentringtone').innerHTML = payload.ringtone.name;
			this.currRingtonePath = payload.ringtone.fullPath;	
		}
		else 
			$('currentringtone').innerHTML = $L("Pick a ringtone");
		
	},
	
	showAudioFilePicker: function(event) {
		var params = {"kinds": ["ringtone"],"filePath":this.currRingtonePath,"onSelect":this.selectedAudioFile.bind(this),actionType:"attach",actionName: $L("Done")};
		Mojo.FilePicker.pickFile(params,Mojo.Controller.stageController);
	},
	
	selectedAudioFile: function(file) {		
		//var params = {"fullPath": encodeURIComponent(file.fullPath), "name":file.name};
		this.setRingtoneReq = SystemService.setRingtone(file);
		$('currentringtone').innerHTML = file.name;
	},

After this code, for Alerts add:

	// Alert Picking
	getCurrentAlert: function() {
		this.getCurrentAlertReq = SystemService.getAlerts(this.getCurrentAlertQuery.bind(this));
	},
	
	getCurrentAlertQuery: function(payload) {		
		if (payload.alerttone) {
			$('currentalert').innerHTML = payload.alerttone.name;
			this.currAlertPath = payload.alerttone.fullPath;	
		}
		else 
			$('currentalert').innerHTML = $L("Pick an alert");
		
	},
	
	showAlertFilePicker: function(event) {
		var params = {"kinds": ["ringtone"],"filePath":this.currAlertPath,"onSelect":this.selectedAlertFile.bind(this),actionType:"attach",actionName: $L("Done")};
		Mojo.FilePicker.pickFile(params,Mojo.Controller.stageController);
	},
	
	selectedAlertFile: function(file) {		
		//var params = {"fullPath": encodeURIComponent(file.fullPath), "name":file.name};
		this.setAlertReq = SystemService.setAlerts(file);
		$('currentalert').innerHTML = file.name;
	},

And for Notifications add:

	// Notification Picking
	getCurrentNotification: function() {
		this.getCurrentNotificationReq = SystemService.getNotifications(this.getCurrentNotificationQuery.bind(this));
	},
	
	getCurrentNotificationQuery: function(payload) {		
		if (payload.notificationtone) {
			$('currentnotification').innerHTML = payload.notificationtone.name;
			this.currNotificationPath = payload.notificationtone.fullPath;	
		}
		else 
			$('currentnotification').innerHTML = $L("Pick a notification");
		
	},
	
	showNotificationFilePicker: function(event) {
		var params = {"kinds": ["ringtone"],"filePath":this.currNotificationPath,"onSelect":this.selectedNotificationFile.bind(this),actionType:"attach",actionName: $L("Done")};
		Mojo.FilePicker.pickFile(params,Mojo.Controller.stageController);
	},
	
	selectedNotificationFile: function(file) {		
		//var params = {"fullPath": encodeURIComponent(file.fullPath), "name":file.name};
		this.setNotificationReq = SystemService.setNotifications(file);
		$('currentnotification').innerHTML = file.name;
	},

Copy your desired notification sounds to the "ringtones" directory in /media/internal/ringtones and they will be visable in the FilePicker.

Save all the files, upload them to the correct locations on the device, and reboot!

Add a Separate Sound for Messages

Check out the message-sound mod to specify the sound played on an incoming message, distinct from the alert and notification sounds.

Copy original notification.wav to ringtones folder

cp /usr/palm/sounds/notification.wav /media/internal/ringtones

Credits

Submitted by Kaerey