Reply
Thread Tools
happosai's Avatar
Posts: 10 | Thanked: 7 times | Joined on Mar 2013 @ UK
#1
The tone I currently have set for SMS alerts (incoming texts) lasts for several seconds, to increase the chance of me hearing it when I'm in a noisy environment, in a different room to the handset, etc.

Sometimes, however, I would like to be able to manually silence the alert rather than letting it playing all the way through, e.g. when the 'phone is close by, I'm in a quiet public area, etc.

On previous Nokia smartphones I've owned, I could do this simply by pressing a button, sliding the unlock switch, tapping the screen, etc. This meant that I could quickly silence an alert without even taking the 'phone out of my pocket.

On my N900, however, the only way I've found to silence an SMS alert is to open the incoming text message, which can take several seconds to do when the handset is locked and in my pocket (and means making even more noise by taking the 'phone out).

Flipping the handset over doesn't appear to silence SMS alerts, as it does for incoming calls or alarms.

Does anyone know if there is an existing way to quickly silence SMS alerts on the N900, or if it would be possible to create a D-Bus script to do this that triggers on pressing the power button or sliding the unlock switch (I would try creating this myself, but don't know what I would have to do to stop a currently-playing alert)?

[Happosai]
 

The Following User Says Thank You to happosai For This Useful Post:
happosai's Avatar
Posts: 10 | Thanked: 7 times | Joined on Mar 2013 @ UK
#2
I've looked more into implementing this via D-Bus (not something I have much experience with).

I found a wiki entry about the com.nokia.HildonSVNotificationDaemon D-Bus interface, which I suspected was used for SMS alerts.

I entered

Code:
dbus-monitor interface=com.nokia.HildonSVNotificationDaemon
in a terminal window and sent a text to my phone, which resulted in

Code:
method call sender=:1.32 -> dest=com.nokia.HildonSVNotificationDaemon serial=694 path=/com/nokia/HildonSVNotificationDaemon; interface=com.nokia.HildonSVNotificationDaemon; member=PlayEvent
	array [
		dict entry(
			string	"urgency"
			variant	byte	1
		)
		dict entry(
			string	"vibra"
			variant	string 	"PatternIncomingMessage"
		)
		dict entry(
			string	"sound-file"
			variant	string	"messaging_and_title_3"
		)
		dict entry(
			string	"category"
			variant	string	"sms-message"
		)
		dict entry(
			string	"persistent"
			variant	byte	1
		)
		dict entry(
			string	"time"
			variant	int64	1363190279
		)
	]
	string	":1.25"
which seems to confirm my suspicions.

The com.nokia.HildonSVNotificationDaemon interface has a StopEvent method, which I assume is what can be used to stop a currently-playing event.

Now I've reached the limit of my understanding. Is there a way to find currently-active events sent to com.nokia.HildonSVNotificationDaemon using PlayEvent, filter out those associated with an SMS alert (category=sms-message?) and then stop them using StopEvent?

[Happosai]
 

The Following 2 Users Say Thank You to happosai For This Useful Post:
woody14619's Avatar
Posts: 1,455 | Thanked: 3,309 times | Joined on Dec 2009 @ Rochester, NY
#3
Originally Posted by happosai View Post
I've looked more into implementing this via D-Bus (not something I have much experience with).
It looks like you've found 90% of what you need to do this. While I'm not 100% up to snuff on D-bus either, I do have one pointer for you that may be interesting as an option: Queen BeeCon Widget has D-Bus trigger-able support.

This would allow you to have say an on-desktop widget (or even one per desktop) that would activate when a text starts, and if pressed could send the corresponding stop command? An app would probably be better/faster, but given this as a tool, it could at least be used to quickly test your theory and act as a fill-in until something permanent comes along.
__________________
Maemo Council Member: May 2012 - November 2012
Hildon Foundation founding member.
Hildon Foundation Board of Directors: March 2013 - Jan 15, 2014
 

The Following 2 Users Say Thank You to woody14619 For This Useful Post:
Posts: 189 | Thanked: 171 times | Joined on Jul 2011
#4
Originally Posted by woody14619 View Post
It looks like you've found 90% of what you need to do this. While I'm not 100% up to snuff on D-bus either, I do have one pointer for you that may be interesting as an option: Queen BeeCon Widget has D-Bus trigger-able support.

This would allow you to have say an on-desktop widget (or even one per desktop) that would activate when a text starts, and if pressed could send the corresponding stop command? An app would probably be better/faster, but given this as a tool, it could at least be used to quickly test your theory and act as a fill-in until something permanent comes along.
Can you just silence the speakers with some amixer magic?? I have never tried but it would be a simple dirty way of doing it, when an SMS is received if the keboard is opened/screen is unlocked in under 5 seconds it mutes the speakers for 5??
Of course, this is the 'wrong' way of doing it but it might work to the extent you need without looking into silencing the actual SMS ring event through more Dbus magic (which might not be possible anyways )
I seem to recall I read somewhere amixer could be used for that under Debian on the N900, let's see if I can dig that up...
 
happosai's Avatar
Posts: 10 | Thanked: 7 times | Joined on Mar 2013 @ UK
#5
Thanks for the suggestions so far.

I've has a go at using dbus-scripts, but unfortunately it doesn't pass sufficient details to determine whether an event is due to an SMS alert, or the ID needed to stop it.

I'll see if I can come up with an alternative way of doing it (including looking at QBC).

[Happosai]
 
happosai's Avatar
Posts: 10 | Thanked: 7 times | Joined on Mar 2013 @ UK
#6
It looks like using a Python script is the way to go, as it has bindings for D-Bus.

I think what I need to do is have two scripts running, one that:
  • monitors D-Bus for a call to the PlayEvent method of the com.nokia.HildonSVNotificationDaemon interface
  • captures the method return value, which is an ID and looks like the following in dbus-monitor:

    Code:
    method return sender=:1.21 -> dest=1.32 reply_serial=694
    	int32 <ID VALUE>
    (the reply_serial value appears to be what connects the method call and return)
  • determines if the PlayEvent method was called due to an sms message (category = sms-message)
  • if so, writes the ID to a file

and one that:
  • monitors D-Bus for a particular hardware event (power button pressed, unlock switch slid)
  • reads the ID written to the file by the other script (if any)
  • calls the StopEvent method of the com.nokia.HildonSVNotificationDaemon interface with that ID
  • deletes the ID from the file

The latter script shouldn't be too difficult. However, I'm not very familiar with either Python or D-Bus, so am struggling with the first script.

[Happosai]
 
Estel's Avatar
Posts: 5,028 | Thanked: 8,613 times | Joined on Mar 2011
#7
You may also be interested in shortcutd program from the repos, as it allows to assign custom terminal commands (including scripts or whatsnot) to half-press of camera button - both long and short.

This way, your silencing script could be run by pressing camera button in your pocket, instead of taking whole device out to access desktop widget.

Of course, proper way to implement this would be replicating ways of silencing phone signal (maybe you should post a enchancement request at CSSU bugtracker? Your point is absolutely valid), but it would require some coding (and some good coding, too, if one would like to write it right, without taxing battery due to polling - relying on IRQ, instead).

/Estel
__________________
N900's aluminum backcover / body replacement
-
N900's HDMI-Out
-
Camera cover MOD
-
Measure battery's real capacity on-device
-
TrueCrypt 7.1 | ereswap | bnf
-
Hardware's mods research is costly. To support my work, please consider donating. Thank You!
 

The Following 2 Users Say Thank You to Estel For This Useful Post:
happosai's Avatar
Posts: 10 | Thanked: 7 times | Joined on Mar 2013 @ UK
#8
I'm familiar with shortcutd, as I already use it to switch tasks using the camera button.

Catching hardware button/switch events to trigger a script isn't actually that difficult, though.

I've thought of a better way of implementing this idea without using multiple scripts and an external file and found some Python code to use as a basis for it. I'll see if I can come up with a proof of concept.

[Happosai]
 
qwazix's Avatar
Moderator | Posts: 2,622 | Thanked: 5,447 times | Joined on Jan 2010
#9
Shotgun method but I would just use shortcutd to run a script that turns the volume to zero and back to what it was after 5 seconds.

You can control the volume with
Code:
amixer -c0 cset numid=ID VALUE
you can find what you need to tweak going into alsamixer -c0
__________________
Proud coding competition 2012 winner: ρcam
My other apps: speedcrunch N9 N900 Jolla –– contactlaunch –– timenow

Nemo UX blog: Grog
My website: qwazix.com
My job: oob
 
happosai's Avatar
Posts: 10 | Thanked: 7 times | Joined on Mar 2013 @ UK
#10
Unfortunately, shortcutd doesn't work when the 'phone is locked.

[Happosai]
 
Reply


 
Forum Jump


All times are GMT. The time now is 16:18.