Execute a command when an SMS is received?
-
I'd like to send a notification to my desktop and laptop when I receive a text message. Is this possible?
Or more properly: what happens in the OS when an SMS is received and where would I find more information about this?
Thanks
-
Currently, no, it is not possible. Someone had started looking at implementing support for KDE Connect, but I'm not sure how far they got.
-
Something which comes into my thinking: the SMS is stored into a table on a sqllite database and if this allows triggers to fire...
-
@guru Thanks, I managed to hack something together, but had to install inotify-tools:
#!/bin/bash # location of databse storing text messages (table is "text_events") DB="/home/phablet/.local/share/history-service/history.sqlite" # location of scripts to run when a text is received SCRIPTDIR="/home/phablet/bin/text.d" function check { # current time in seconds since epoch CURRENTTIME=$(date +%s) # get senderid (phone number) and timestamp from most recent entry in text_events table of $DB at time of modification SENDERID=$(sqlite3 $DB "SELECT senderid FROM text_events ORDER BY timestamp DESC LIMIT 1;") # timestamp converted to seconds since epoch TIMESTAMP=$(date -d$(sqlite3 $DB "SELECT timestamp FROM text_events ORDER BY timestamp DESC LIMIT 1;") +%s) # calculate difference between when text was received and $CURRENTTIME DIFFERENCE=$(expr $CURRENTTIME - $TIMESTAMP) if [ $DIFFERENCE -lt 2 ] && [ $SENDERID != "self" ] then # run all scripts in #SCRIPTDIR run-parts $SCRIPTDIR else : fi } # monitor $DB for changes and execute the above function if it is modified while inotifywait -e modify $DB; do check; doneThere are probably much better ways of going about this but it works for now

Any pointers appreciated.
EDIT: Terrible code updated a bit
-
Check if sqllite supports triggers. If so you could attach a trigger to any table XYZ and any INSERT into that table will fire your own written piece of software.
-
You could also monitor the system dbus, sms appears in clear text on it.
Sorry I can't copy paste from terminal , maybe a bug.
sudo dbus-monitor --system "type='signal', interface='org.ofono.MessageManager'" -
Looks like triggers are supported but only UPDATE/INSERT/DELETE/SELECT are allowed in the trigger body (trying to use .shell gives a syntax error).
Close but no cigar

-
Thanks, this is really cool. I did a test sending
Testing dbusto my UBphone:$ sudo dbus-monitor --system "type='signal', interface='org.ofono.MessageManager'" [sudo] password for phablet: ... string "Testing dbus" array [ dict entry( string "LocalSentTime" variant string "2020-01-12T20:26:33+0100" ) dict entry( string "SentTime" variant string "2020-01-12T20:26:33+0100" ) dict entry( string "Sender" variant string "+49170xxxxxxxx" ) ] ^C -
@AlainW94 Thanks, this looks promising.
-
Happy to help !

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login