Simply follow these steps:
If you prefer to do it using a GUI, you can go to the Software Center and install Scheduled tasks (or run sudo zypper install gnome-schedule). It will provide a powerful GUI to add cron tasks.
Note that if you use this method, tasks by default will be executed as your own user, not as root. This is usually a good thing.
Once installed this application, search "Scheduled Tasks" and Open it.
Now, Click on New
Click on "A task that launches recurrently"
Now Add description for example: VK Battery Check
On the command, Add: /home/vkpandey/Extras/scripts/CheckBattery.sh
On the Time and Date Option, click on Advanced
In the Minute section, add */5 that means at minute: */5 (in every 5 minutes)
and leave Hour, Day, Month, Weekday *
Now create a following CheckBattery.sh script in any location (For example: /home/vkpandey /Extras/scripts)
#!/bin/bash**Don't forget the file permission of CheckBattery.sh
BATTERY=$(upower -e | grep 'BAT')
while [ 1 ]
do
BATTERY_PERCENTAGE=$(upower -i $BATTERY|grep percentage|awk '{ print $2 }'|sed s/'%'/''/g)
if [[ "$BATTERY_PERCENTAGE" -lt "20" ]]; then
notify-send --urgency=critical "WARNING: Battery is about to die" "Hello Vijaya!! Plug in the power cable"
play /usr/share/sounds/KDE-Sys-Warning.ogg &> /dev/null
fi
sleep 10
done
Now All Done!
No comments:
Post a Comment