@AlainW94 Thanks, this looks promising.
Q
Latest posts made by Quaigon_Jim
-
RE: Execute a command when an SMS is received?
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
-
RE: Execute a command when an SMS is received?
@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; done
There are probably much better ways of going about this but it works for now
Any pointers appreciated.
EDIT: Terrible code updated a bit
-
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