maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails (https://talk.maemo.org/showthread.php?t=101005)

Veraendert 2020-04-16 18:58

Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails
 
Dear colleague, we use this one now: https://www.alamos-gmbh.com/service/apager-pro/
The whole Landkreis (county?) is supposed to use it. Best part is that it also shows me the way to the fire station should i have forgotten how to get there.

@all: You guys are great. I now have a separate email account, with situation set up so that when i´m not within reach of a known wifi the ambient changes and thus the sound when i get an email. Emails are constantly retrieved for the alarm mail account and only manually for the normal one. I think i can live with that for the time being.

I'll probably try to retrieve the alarm message via kdeconnect with a linux computer later to gain a few seconds and to be able to forward the message via different means.

One last question though: the Situations app lets me execute random commands it seems. Does anyone have any idea how to put this possibility to use?

peterleinchen 2020-04-16 19:48

Re: Please help a firefighter
 
I just found some time to hack together a shell one-liner that should solve it for you (jn case your alert e-mail has a specific unique subject):
Code:

{ dbus-monitor & echo $! >dbusmonpid; } | { grep -q -m 1 'xxxSUBJECTxxx' && gst-launch-1.0 playbin uri=file:///home/nemo/Music/SOMEFILE.ogg.midi.wav.mp3 && kill $(cat dbusmonpid) && rm dbusmonpid; }
Replace the xxxSUBJECTxxx with any unique part of subject of your alert mail. And replace SOMEFILE with any music /sirene/noise sound file.
Tested and worked. :)



This is definitely not fool proof and could be extended with a loop and more. Oh and let the sound play to end (do not use ctrl-c), else the dbus-monitor process will not get killed.
About loudness I do not know with gst-launch but there should be some help.
So there is room for improvement. But hey it works!

Thanks @haltux for the right pointers! :D

ajalkane 2020-04-16 20:03

Re: Please help a firefighter
 
If you can make the alerts come as SMS with predefined message, you could also use FindMyJolla to create alert:

https://openrepos.net/content/ajalkane/find-my-jolla

Halftux 2020-04-16 20:47

Re: Please help a firefighter
 
Quote:

Originally Posted by peterleinchen (Post 1566897)
So there is room for improvement. But hey it works!

Thanks @haltux for the right pointers! :D

Nice one I am glad that I could be of help with this outcome :)
Very good and flexible starter.
I could also think of, that you not filter the subject which is good, but when needed you could also filter the account which gets an e-mail.
Just as an idea when the subject changes.

Veraendert 2020-04-17 06:21

Re: Please help a firefighter
 
This sounds great, i'll test it. I should probably make this a cron job to start on boot, no?
I can define the message myself so that shouldn't be a problem.
Volume should be easy: https://gstreamer.freedesktop.org/do...ume/index.html

peterleinchen 2020-04-17 07:31

Re: Please help a firefighter
 
You are welcome.
Fire fighters are system relevant ;) so I needed to help :D

About volume level I found that gstreamer thing also but think this is just setting 0-100 % of actual level (not sure).
So I think this approach here sounds better:
Code:

after installing alsa-utils via pkcon I was able to change the master volume/balance via cmd line like 'amixer sset Master 80%,80%'


The current code snippet I made is a one-time executer, so you would need to put into a loop. I thought it is easier to control when you want it to run. If you want it always, a systemd script on boot or cron job is good. But then it would need some more fine tuning against reliability, e.g. how to stop it or how to pause/stop the sound...

Veraendert 2020-04-17 09:11

Re: Please help a firefighter
 
Just in case a colleague of mine finds this: I had to install gstreamer1.0-tools, too

Veraendert 2020-04-17 11:07

Re: Please help a firefighter
 
So after install alsa-utils and gstreamer1.0-tools i'm now here:
Code:

{ dbus-monitor & echo $! >dbusmonpid; } | { grep -q -m 1 '<alarm>' && amixer sset Master 100%,100% && gst-launch-1.0 playbin uri=file:///home/nemo/Documents/sirene.mp3 &&
kill $(cat dbusmonpid) && rm dbusmonpid; }

This is a working solution.

peterleinchen 2020-04-17 12:04

Re: Please help a firefighter
 
Quote:

Originally Posted by Veraendert (Post 1566914)
So after install alsa-utils and gstreamer1.0-tools i'm now here:
...
This is a working solution.

Now as we know the trigger subject text we just need your e-mail address to test! :D

Would you mind to edit the first post and hereby the title to some more meaningful?
Like: Help a firefighter - trigger alarm.mp3 by monitoring incoming e-mails

--
and maybe reset loudness after sound has played?

Veraendert 2020-04-17 14:17

Re: Please help a firefighter
 
Quote:

Originally Posted by peterleinchen (Post 1566915)
Now as we know the trigger subject text we just need your e-mail address to test! :D

I'm not that stupid :D

Thank you all for your input. I'll try to figure out how to make a systemd service from this that also resets sound volume.


All times are GMT. The time now is 11:25.

vBulletin® Version 3.8.8