![]() |
2010-05-14
, 14:55
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#12
|
![]() |
2010-05-18
, 02:32
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#13
|
#! /usr/bin/env python2.5 # # callergroup - Assign Ringtone By Caller-Group for N900 v0.0.2 # By 9000 @ maemo.org/phonehk.com 14-May-2010 # # ATTENTION: Use the script at your own risk. You're responsible for any damage that'd cause by using this script. # LIMITATION: Lots. Like lacking fancy UI, insufficient format support (WAV only), etc. # FEATURE: 1) Assign different ringtones to caller-groups you defined. 2) Block calls # CHANGELOG: 18-May-2010: Add blocking function # # Usage: # 1) Move your default ringtone to /home/user/.local/share/sounds/callergroup/ , I choose Gradient.acc.wav in this example # mkdir -p /home/user/.local/share/sounds/callergroup/ # mv /home/user/.local/share/sounds/Gradient.acc.wav /home/user/.local/share/sounds/callergroup/. # # 2) Symlink your default ringtone back to /home/user/.local/share/sounds/ , Gradient.aac.wav in this example # ln -sf /home/user/.local/share/sounds/callergroup/Gradient.aac.wav /home/user/.local/share/sounds/Gradient.aac.wav # # 3) Copy any wav files you'd like to set for the groups. I use ringtone_for_group_X.wav in this example # cp /media/mmc1/ringtone/*.wav /home/user/.local/share/sounds/callergroup/. (just an example) # # 4) Customize the telephone number and ringtone file name in the CUSTOMIZATION section below # # 5) Run the script # /usr/bin/python ./callergroup.py # import gobject, dbus import time import os from dbus.mainloop.glib import DBusGMainLoop def handle_call(obj_path, callernumber): global blocklist print 'Calling from '+callernumber+'...' # Caller group found: if callernumber in group_info: assigned_group = group_info[callernumber] group_ring = group_ringtones[assigned_group] print 'Caller belongs to Group:'+assigned_group+', ringtone assigned:'+group_ring+'.wav' bus = dbus.SessionBus() profiled = bus.get_object('com.nokia.profiled', '/com/nokia/profiled') proxy = dbus.Interface(profiled, 'com.nokia.profiled') system_ring = os.path.basename(proxy.get_value('general','ringing.alert.tone')) os.system('ln -sf /home/user/.local/share/sounds/callergroup/'+group_ring+'.wav /home/user/.local/share/sounds/'+system_ring+'.wav') # Call blocking: elif callernumber in blocklist: print 'Caller from '+callernumber+' blocked' bus = dbus.SystemBus() callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1') smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance') smsiface.Release() # Default: else: print 'Caller has no assigned group' bus = dbus.SessionBus() profiled = bus.get_object('com.nokia.profiled', '/com/nokia/profiled') proxy = dbus.Interface(profiled, 'com.nokia.profiled') system_ring = os.path.basename(proxy.get_value('general','ringing.alert.tone')) os.system('ln -sf /home/user/.local/share/sounds/callergroup/'+system_ring+'.wav /home/user/.local/share/sounds/'+system_ring+'.wav') # ---CUSTOMIZATION--- # # The telephone numbers to block blocklist = ["11709394","53540997"] # Change the name of the ringtones for the corresponding groups group_ringtones = { 'GroupA':'ringtone_for_group_a', 'GroupB':'ringtone_for_group_b', 'GroupC':'ringtone_for_group_c', } # Associate the telephone numbers to the groups group_info = { '77777777':'GroupA', '88888888':'GroupB', '12345678':'GroupB', '87654321':'GroupC', } # ---END OF CUSTOMIZATION--- # DBusGMainLoop(set_as_default=True) bus = dbus.SystemBus() bus.add_signal_receiver(handle_call, path='/com/nokia/csd/call', dbus_interface='com.nokia.csd.Call', signal_name='Coming') gobject.MainLoop().run()
![]() |
2010-06-07
, 21:53
|
Posts: 267 |
Thanked: 183 times |
Joined on Jan 2010
@ Campinas, SP, Brazil
|
#14
|
![]() |
2010-06-11
, 02:18
|
Posts: 200 |
Thanked: 15 times |
Joined on Dec 2009
@ São Paulo - Brasil
|
#15
|
Bump this thread! Has anyone tried it with PR1.2? I hope this script rapidly evolves to a 'ringtone by contact group' app!
![]() |
2010-06-11
, 02:27
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#16
|
![]() |
2010-06-11
, 04:12
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#18
|
![]() |
2010-06-11
, 04:49
|
Posts: 195 |
Thanked: 102 times |
Joined on Feb 2010
@ Vancouver, Canada
|
#19
|
![]() |
2010-06-11
, 06:16
|
Posts: 1,425 |
Thanked: 983 times |
Joined on May 2010
@ Hong Kong
|
#20
|
Let me see if there's a way to delay the ring...