Benjamin-Loison / matrix-commander

simple but convenient CLI-based Matrix client app for sending and receiving
GNU General Public License v3.0
0 stars 0 forks source link

Be notified with `matrix-commander` on a given command execution end #23

Closed Benjamin-Loison closed 2 months ago

Benjamin-Loison commented 2 months ago
ps aux | grep '[r]epo -- sync'
debian      1705  1.3  0.7 860172 502572 pts/0   Sl+  14:05   0:05 /usr/bin/python3 /home/debian/.repo/repo/main.py --repo-dir=/home/debian/.repo --wrapper-version=2.45 --wrapper-path=/home/debian/bin/repo -- sync
...
ps aux | head -n 1
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
Benjamin-Loison commented 2 months ago
while [ 1 ]
do
    date
    sleep 1
done

has a varying PID.

date
sleep 10
date
tail --pid=PID -f /dev/null; date; matrix-commander -m 'Process finished!'

Source: the Stack Overflow answer 41613532

Benjamin-Loison commented 2 months ago
 matrix-commander() {
    MESSAGE=`python3 -c "import urllib.parse as ul; print('message=' + ul.quote_plus(\"$1\"))"`
    KEY=CENSORED
    curl -G -s 'https://lemnoslife.com/BEN/notify.php' -d $MESSAGE -d "key=$KEY"
    unset KEY
}
grep -m 1 KEY /var/www/html/BEN/notify.php
matrix-commander 'Process finished!'
Benjamin-Loison commented 2 months ago

Related to Benjamin-Loison/waydroid/issues/16.