Reply
Thread Tools
Posts: 94 | Thanked: 253 times | Joined on Jan 2010 @ Virginia
#1
This will be my first technical post as well as my first N900 hack! I am not a programmer or a developer I just have too much time.

One day I had an idea to set my phone's SMS alert to a random Starcraft unit selection sound. After much tweaking and trial and error I am now very pleased with my hack.

What I did was download the SC1 sound pack from teamliquid onto my device.

After much trial and error I found the location of the cached SMS alert wave files. I then created a placeholder wav file called randomsc.wav somewhere in the MyDocs directory using an existing wav file.

I then created a named pipe at /home/user/.local/share/sounds/randomsc.wav.wav (The phone encodes whatever file you select and appends a .wav to it when selecting an alert)

Code:
mkfifo /home/user/.local/share/sounds/randomsc.wav.wav
I then set the alert to my placeholder wav file (the phone sees that it is already cached and does not attempt to re-cache it)

All I had to do now was pipe random wav files into the named pipe. I created an index of the files to be randomized with

Code:
find /home/user/MyDocs/SC1S/Sounds/ | grep wav > /home/user/list.txt
/home/user/MyDocs/SC1S/Sounds/ is the location of the soundpack of the wav files to be randomized

With the index created I now just have to pipe random entries into the named pipe with:

Code:
while true; do /usr/bin/gnu/shuf /home/user/list.txt | head -n 1 | xargs cat 1>/home/user/.local/share/sounds/randomsc.wav.wav; done
What this did was loop cat random files into the named pipe randomsc.wav.wav. this also requires the coreutils-gnu package to be installed in order to use the "shuf" command. The above code will loop infinitely until the task is terminated. While that code was running any SMS I received was a random Starcraft Unit selection sound.

There are many problems with this set-up and it is not ideal. It could be improved several ways.

1. If the device were to be plugged into a computer in mass storage mode and you were to receive an SMS it would cause lots of problems (this could be avoided if you put the sound files into the rootfs)
2. The loop command has to be run in order for any of this to work and this needs to be daemonized.
3. Deleting sound files might cause an SMS alert to be missed

This named pipe feature seems very extensible to me. So i tried piping espeak into the fifo and viola dynamic tts SMS alert.
Code:
while true; do date | espeak -w /home/user/.local/share/sounds/randomsc.wav.wav; done
I also believe this concept to be extended to Per-Contact Ringtones as the regular ringtones use the same method. You could make a simple python script catch a dbus message and look up the number and pipe the relevant ringtone.

I think this is very cool method to generating dynamic ringtones and I can't wait to try out per contact ringtones. I'm also not a developer but I'm sure some of you out there can take my concept and make it user friendly and refined.

I am not familiar with upstart so I have no idea how to make the loop run at startup

Last edited by Dotblank; 2010-04-08 at 17:22.
 

The Following 9 Users Say Thank You to Dotblank For This Useful Post:
fcrochik's Avatar
Posts: 722 | Thanked: 1,223 times | Joined on Apr 2010 @ USA
#2
Just to finish the "circle", and in case you missed, there is a thread about how to assign ring tones to groups using python here
__________________

My maemo work:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
For Harmattan:
GeePS - native UI around google maps - GApp - access to optimized mobile "google apps".
Shutdown - shutdown and reboot with one click - QuickCall - one click call, skypeout and google voice integration using dial tones.
WakeOnLan - wake computers on your local network.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
For Maemo/N900:
GApp - access to optimized mobile "google apps". - MobWebMail: browser optimized to access multiple gmail accounts
MyContacts: 75 Contacts on your desktop, ring tones per group and more - GeePS: native front-end for google maps
Macuco2 : web browser to access web sites optimized for the iphone - WakeOnLan: wake up computers on your local network
dbBrowser: Simple application to browse sqlite databases

Last edited by fcrochik; 2010-06-21 at 00:35.
 

The Following User Says Thank You to fcrochik For This Useful Post:
Posts: 307 | Thanked: 157 times | Joined on Jul 2009 @ Illinois, USA
#3
Cool stuff! How about a video of this in action?
 
Reply


 
Forum Jump


All times are GMT. The time now is 02:21.