So I wrote a little script that makes sure a certain user plugs in a laptop when he logs on (it disables if he doesn't). The script uses notify-send to tell him to plug it in. If he plugs it in, the script quits. Is it possible to clear the notification automatically when he plugs it in? I'm thinking it might require somehow getting the process id spawned by notify-send and killing that PID, but I don't know how to do this.
Here's the current script:
#!/bin/bash
cat /sys/class/power_supply/BAT0/status
OUTPUT="$(cat /sys/class/power_supply/BAT0/status)"
echo "${OUTPUT}"
if [ "${OUTPUT}" = "Charging" ] || [ "${OUTPUT}" = "Unknown" ]; then
echo charging or full
elif [ "${OUTPUT}" = "Discharging" ]; then
notify-send -i /home/evamvid/Documents/Programming/OokiNoUse/power25.png "Hey there brother" "plug it in"
COUNTER=0
while [ "$COUNTER" -le 12 ]
do
cat /sys/class/power_supply/BAT0/status
OUTPUT="$(cat /sys/class/power_supply/BAT0/status)"
echo "${OUTPUT}"
if [ "${OUTPUT}" = "Charging" ] || [ "${OUTPUT}" = "Unknown" ]; then
exit
elif [ "${OUTPUT}" = "Discharging" ]; then
COUNTER=$(($COUNTER+1))
echo $COUNTER
sleep 1
fi
done
fi