![]() |
[HOW TO] Assign Ringtone by Caller-group for N900
This script is made in response to all those "IT CAN'T BE DONE" posts. Consider this as a demonstration rather than an application. However, if you've a pressing needs of caller-group ringtones, you may use the script (with caution).
Hope this help. Code:
#! /usr/bin/env python2.5 http://maemocentral.com/2010/02/22/h...s-on-the-n900/ http://www.maemoers.com/archiver/tid-2364.html |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
system_ring = os.path.basename(proxy.get_value('general','ringin g.alert.tone'))
haven't tried this but I'm guessing that is a rogue space embedded in the above line? |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
Thanks for pointing it out promptly. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Thanks for this. For future reference, you might want to know that you can wrap code with [code] tags to make it appear nicer, keeping indents etc.
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Can I just make sure I've got the general idea of your program correct, based on my inexpert reading of the code: The program runs continuously in the background. When it detects an incoming call, it quickly changes the system-defined ringtone using a symbolic link, based on a lookup of which phone number should be in which group. The actual playing of the tone is done by the phone app itself. Is that right?
I'm just wondering what happens if for some reason the phone app gets there first and starts playing a different ringtone, before your app gets a chance to change the symlink. Will the ringtone change half-way through? Does your app impact battery life, if it is running in the background all the time? Thinking about a potential GUI, obviously there would need to be a way to define groups (giving each a custom name would be nice), plus a way to pick a ringtone per group. Then there would need to be a way to associate a contact with each group. I wonder if there's a way to hook into the contacts framework to do this. Maybe the group could be stored as a Note field in the contact, or something like that. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Hi Pelago,
Quote:
[/quote] I'm just wondering what happens if for some reason the phone app gets there first and starts playing a different ringtone, before your app gets a chance to change the symlink. Will the ringtone change half-way through? [/quote] The script setup an event loop to pick up signal. I'm sure the race condition you've mention would happen. Anyone would suggest a better way to preempt the ringing would be welcome. ^^ Quote:
Quote:
However, creating extra column in each contact and have the program read that column to determine its ringtone is a very good idea. It doesn't require much effort to accomplish. May be I would enhance it a bit for that... later. ^^ |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Did you actually test this?
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Funny. When I tried this method, my script was always running too late, and the phone application played the previous ringtone.
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
LOL, you got a real fast phone app! I don't have that problem.
Let me see if there's a way to delay the ring... |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Strange....while I've tested the script under all loading condition, it can still pickup the correct ringtone to play. I can't seem to reproduce the race condition you've experienced.
Let me check the dbus documentation again. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
1 Attachment(s)
Though I still couldn't reproduce Matan's race condition, but may be running a compiled version would help. Anyway.
I made a slight modification to the script, including call-blocking function. I know there's already pycallblocker around for use, but I think some people would like it to be incorporated into one. I'm still working on pelago's suggestion on using contact list and making UI(my weakest part), but for the time being just edit the script if you need to use it. ^^ Code:
#! /usr/bin/env python2.5 http://maemocentral.com/2010/02/22/h...s-on-the-n900/ http://www.maemoers.com/archiver/tid-2364.html |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Bump this thread! Has anyone tried it with PR1.2? I hope this script rapidly evolves to a 'ringtone by contact group' app!
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
I used PR1.2 from start so I guess it'd work for your PR1.2 as well.
Just that if you've real fast CPU (or real slow phone app) there's race condition as described by other posters above. I wish I had time to improve the script. Any suggestion is welcome. ^^ |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
i suggest you use a variable to record the default ringtone info.
becase use DBUS object to detect info should be slow. sorry for my poor english. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
mp3 ringtones (and alarm tones) have crackling sounds with the n900 anyways, haven't you guys noticed this problem?
https://bugs.maemo.org/show_bug.cgi?id=6784 |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
No.
You may open a new thread for this. Specify clearly the firmware version you're using would help. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Thanks 9000, for this beauty script. I wanted to know if you got it working to automatically exec on boot? I tried on the basis specified by Jussi in http://www.mynokiaworld.com/2010/02/...-on-your-n900/
But for some reason the process is not starting. could you please help me out. Thanks |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Thanks, I'll show you how to make it starts on startup later on.
Regarding your issue, if you run it directly it should wait for a call indefinitely. Any strange message seen when it exits adnormally? |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
I am trying to implement this feature on my qt application but w/o much luck. Maybe we can compare notes:
1. I first tried to change the ring tone using dbus on the fly when receiving a call but it did not work. the phone just seems to go back to the default ring tone if you try to change it after the coming signal. 2. then I tried to just implement this solution but thought I could use no file extension for my symlink name first and then tried with mp3. It seems that the phone application either cache the file or resolves the symlink and store the absolute path when you first assign the ring tone to the profile. did you try other methods before getting to this solution? is that why you created the sym link with a wav file extension? p.s. it does not seem to work on mine regardless of the file extension... the first time I set the profile ring tone to the symlink it works... if I change the symlink target the phone keeps playing the original file.... am I missing something? Thanks |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Hi frochik,
1. The reason to change symlink instead of changing the acually default is the speed. There might not be enough time between call coming and ringtone playing unless we can put the ringing on hold. 2. Changing the symlink serves as redirection of the pointer to the ringtone. I'd have changed the actually pointer directly if I knew where it is, so this method is in fact tricking the phone app to play different physical files by changing the symlink. It don't matter what default ringtone you choose, the script just make of the file name. If it played the same ringtone over and over the symlink in question probably broken. You would like to rebuild manually. I think I'll modify the script to include this checking, thanks for your input. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
I haven't tried this myself yet (gotta pick a day to settle down and do all the N900 stuff). Though how quick is it? Will it instantly play the new ringtone or is there a silent pause when someone calls?
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
Actually I'd rather controlling it to prevent race condition. Anyone would show me how is much appreciated! |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
thanks for reply m8. i will wait for the startup and the complete package :D. with respect to process not starting, i meant the actual startup process defined in event.d and init.d. Script (directly executed) is running without problems. Thanks again m8, this a very very useful script, patching the disadvs of N900. As i said earlier, i would love to wait for this script to turn into a lovely feature (which is actually quite a necessity -- supported by almost all phones in this range!!) binded into the OS / contacts. Hopefully it happens by next OS update.
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
@getnani The script doesn't has much error handling so running it at startup would cause all the calls playing default Nokia ringtone when the script encountered any errors. I can post the startup script if you like anyway...
@Manul I've not encountered any caching problem, may it could be disabled somehow. I'll keep track of your post thanks. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
BTW, this script can be considered as a workaround solutions for caller-group ringtone as all it does is monitoring the calls. The race condition cannot be prevented in monitoring mode. Though I've not encountered the problem, but someone else did, and in fact it's possible.
I'd consider making a package out of it if I can figure out the to control the calling flow so as to prevent the race condition. Please advise if you could find any hints. Thanks. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
okay. I guess that is why the script hangs on start. am not sure... anyways thanks for offering the start script. Just to let you know, the script hangs after a while, say like 4hrs etc. do u expect that? also it sometimes picks the caller tune that shud have been for the prev call!!! is that becos of the race condition?
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
I love the script... I have a suggestion (and a neat tip) that I'd love to see integrated, but I'm not totally up on the dbus stuff enough to do it. Maybe you are?
One interesting feature/hack for texting groups of people is that you can use the "Nickname" field to group people together. If you gave 5 people the nickname "GroupA", for example, then type GroupA into the To: field for a new SMS and hit the To: button, it lists those 5 people for quick selection. I use this already for texting groups of friends. I would love if this script could (instead of making it's own mini database) use calls to ask the address book for people with a Nickname containing "GroupA" to setup the ring tone (and/or text tone?). That would make grouping a lot more integrated. I'm hopeful that someone will make an extension (like the IM extensions) that adds a "Group" field to the address book that everyone can key off of, instead of (ab)using the Nickname field. :) |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Thank you for giving an extensive test to my script ^^
I wondered if the process would be reniced after idling for quite sometime. I've been testing the script all day but hasn't encountered the race condition...yet... Let me try if it helps if the process started with renice. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
However, reading the address book would further delay the ringtone changing process and cause even worse race condition...I must find a way to hold a call before the ringtone is changed. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
i have used renice. thanks for this tip. set it to the highest priority. lets c how this affects. will keep u posted matey.
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
ok i guess there is no effect. i does hang after a while!!
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
hang? The entire device locked?
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
no no.... just the program. device is fine. Anyways, did u guys have a look at eSpeakCaller. Some ideas cud be borrowed from that. esp one global settings for normal profile, and then other bits of configs for exceptions. It guess it also uses py scripts. Just a thought matey, may be wrong.
|
Re: [HOW TO] Assign Ringtone by Caller-group for N900
First of all let me say: Thank you 9000!
I tried implementing this different ways but ended up on the same place you did - pretty much same constraints: only wav files (for now) and trying to compete with the phone application to change the symbolic link before it opens the file. I don't mean to say that I have developed a complete solution for this problem but thought that some people on this thread may want to know that I just release an application (MyContacts) that allow for some ring tone by group. |
Re: [HOW TO] Assign Ringtone by Caller-group for N900
Quote:
|
All times are GMT. The time now is 21:05. |
vBulletin® Version 3.8.8