So I have a bash script which will notify me, if the battery is low.
The script is here
#!/bin/bash
BATTERY=$(upower -e | grep 'BAT')
while :
do
BATTERY_PERCENTAGE=$(upower -i $BATTERY | grep percentage | awk '{ print $2 }' | sed s/'%'/''/g)
CABLE=$(upower -d | grep -n2 line-power | grep online | awk '{ print $3 }')
if [[ "$BATTERY_PERCENTAGE" -lt "10" && $CABLE = "no" ]]; then
notify-send --urgency=critical "WARNING: Battery is about to die" "Plug in the power cable"
fi
sleep 60
done
So I am currently using the dwm window manager with Arch Linux. The issue is that if I just close the window manager, & again launch it, it actually shut down all the programs I was using (for instance flameshot & dunst), but it fails to kill my battery script. Here is my autostart script which I am running in .xinitrc file.
# My .xinitrc file
# This file will run as autostart
dunst &
flameshot &
setxkbmap -option caps:escape &
sxhkd -c ~/suckless/dwm/sxhkdrc &
~/.fehbg &
~/scripts/battery-notification &
xrdb ~/.Xresources &
exec dwm
And I run this file through xorg's startx. If I do a ps -ef | grep battery-notification, it shows more than 2 instances (which include battery script & grep).
Answers are appreciated :)