Good Day, I am new to Linux (Raspberry) and am trying to get notify-send to work from a script (see below).
Notify send works from the terminal CLI and displays on my GUI. But it does not work from the script. I am using Raspberry Buster - with all updates.
#!/bin/bash
# This should point to the pivoyager executable
PIVOYAGER=/usr/local/bin/pivoyager
while true;
do
# Phase 1: Check every 5 seconds if we are USB powered.
# If we are not on USB power, go to phase 2.
while $PIVOYAGER status flags | grep "pg";
do
sleep 5
done
# Phase 2: Do something before shutdown. (optional)
# e.g. send an email, warn users, etc.
#notify-send "We are on Battery Power. Save all your work."
sleep 30
# Just check if power was miraculously restored.
if ! $PIVOYAGER status flags | grep "pg"; then
break
else
notify-send "Power was restored. Shutdown aborted!"
fi
done
# Phase 3: Initiate the shutdown.
# - Enable automatic power on once USB power is restored.
# - Program full power cut in 25 seconds.
$PIVOYAGER enable power-wakeup
$PIVOYAGER watchdog 25
sudo shutdown now
Thanks in advance for your help.