maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Random SMS sound (https://talk.maemo.org/showthread.php?t=90210)

dr_frost_dk 2013-05-24 21:52

Random SMS sound
 
I was wondering if anybody knew of a program or simple script that can intercept SMS and play a random audio file from a folder.

I have a lot of funny audio clips and wanted to have them play at random when i get an SMS.

Now i have already made a few scripts in the past but my memory sometime works like RAM and gets "reset" and im drawing blanks on how to even do DBUS right now, even thou i made something like this for the simple brightness in the past.

vi_ 2013-05-24 23:41

Re: Random SMS sound
 
Quote:

Originally Posted by dr_frost_dk (Post 1346609)
I was wondering if anybody knew of a program or simple script that can intercept SMS and play a random audio file from a folder.

I have a lot of funny audio clips and wanted to have them play at random when i get an SMS.

Now i have already made a few scripts in the past but my memory sometime works like RAM and gets "reset" and im drawing blanks on how to even do DBUS right now, even thou i made something like this for the simple brightness in the past.

Excuse the terse rsponse, I am on n900 over 'borrowed' wifi.

To put it simply you would need to use a script triggered by dbus. You need to use either dbus-scripts, dbuscron or a custom script with some kind of loop and dbus-monitor. When your script intercepts the 'sms received' dbus message it needs to use awk, sed, grep, etc to alter the config file for a given profile. So, populate list of folder of random sounds then replace reference to sound in profile config.

dr_frost_dk 2013-05-25 06:53

Re: Random SMS sound
 
yes that sounds like what i was thinking, my thinking where in the line of turning off sms tone an having the script take over like custom brightness (version 1 :) )

pichlo 2013-05-25 20:14

Re: Random SMS sound
 
This is not quite what you want but might be simpler to implement. Instead of choosing the file when the SMS arrives, choose it for the next SMS that will arrive. A casual user won't notice any difference.

Now how do you do that? You can employ some dbus magic but the simplest approach is, run a cron job that will periodically link the SMS notification file to the next file in your folder. If you receive SMS randomly (as most people do), the effect will be a random file played on the next SMS.

dr_frost_dk 2013-05-26 10:42

Re: Random SMS sound
 
Thanks, i actually like the idea of "next sms" it seems as "less" work for the N900 as it does not have to do it in "real time".

Now i just have to read up on all the DBUS again...., damm this memory

low 2013-05-27 08:37

Re: Random SMS sound
 
dbus-monitor and a test sms is usually what I use to "remember" what to look for when the dbus fires :p

dr_frost_dk 2013-05-27 09:21

Re: Random SMS sound
 
yes i know, just haven’t had the time yet... :(
but when i do ill post in post #1 the "results"

dr_frost_dk 2014-04-04 20:44

Re: Random SMS sound
 
well i been busy or something, but now after almost a year i think i will complete this.... :p

and so far i have this working
FOR TESTING!!
Code:

#! /bin/sh
dbus-monitor --system interface='Phone.SMS',member='incoming' | while grep -q array
do
echo "SMS recieved"
sleep 2
echo "sleep done"
echo " "
done

this works, now i just need some help with what command/edit conf that controls sms sound....

dr_frost_dk 2014-04-04 20:52

Re: Random SMS sound
 
/home/user/.profiled/custom.ini :), will post when i get it working with random (or next audio file)

EDIT: nope not that ini file....

dr_frost_dk 2014-04-04 21:47

Re: Random SMS sound
 
Well... trying to edit a conf to change next does not work....

but adapting my random script for my old diy alarm that would play random sounds from a folder until a random code had been entered to stop it.

Code:

#! /bin/sh
dbus-monitor --system interface='Phone.SMS',member='incoming' | while grep -q array
do
echo "SMS recieved"
dbus-send --type=method_call --dest=com.nokia.mafw.renderer.Mafw-Gst-Renderer-Plugin.gstrenderer /com/nokia/mafw/renderer/gstrenderer com.nokia.mafw.extension.set_extension_property string:volume variant:uint32:80
songdir="/home/user/MyDocs/.sounds/SMS-Random/"
sleep 3

a=$(ls "$songdir" -1 | awk 'BEGIN{srand()} {x[NR] = $0} END{print "", x[1 + int(rand() * NR)]}' | sed 's/^ *//')
mplayer -ao pulse "$songdir""$a"

sleep 1
echo "sleep done"
echo " "
done

So now i set the SMS to beep and volume 0, thinking about making a VERY fast click so i has a click before random sound, as script writes, it echoes "SMS recieved" and waits 3 secons (to clear audio from beep) turns audio up to 80%, and plays random file from folder that is specified (songdir)

taixzo 2014-04-05 04:51

Re: Random SMS sound
 
Why not just make the SMS sound silence? Then you don't need a click sound.

dr_frost_dk 2014-04-05 17:36

Re: Random SMS sound
 
Success with the method of changing next SMS sound.

Code:

#! /bin/sh
dbus-monitor --system interface='Phone.SMS',member='incoming' | while grep -q array
do
echo "SMS recieved"
sleep 1
songdir="/home/user/MyDocs/.sounds/SMS-Random/"
a=$(ls "$songdir" -1 | awk 'BEGIN{srand()} {x[NR] = $0} END{print "", x[1 + int(rand() * NR)]}' | sed 's/^ *//')
sleep 5
cp "$songdir""$a" /home/user/.local/share/sounds/Message1.aac.wav
done

Select "Message1" as ringtone, 1 sms will have the stock tone, every other will have random sounds from defined folder, now just need to make a startup script so i don't have an open terminal all the time :)


All times are GMT. The time now is 09:57.

vBulletin® Version 3.8.8