Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I'm using Ubuntu 12.04 on a laptop, I was wondering if there is a way to get notified when the battery become full.

share|improve this question

marked as duplicate by Glutanimate, Tim, mikewhatever, Eliah Kagan, Eric Carvalho Aug 18 '14 at 10:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

This can be done by running a script. But first i need to know which type of battery you are using.Open terminal.type ls /proc/acpi/battery/. What is the output? – Khurshid Alam Jun 14 '12 at 19:17
up vote 2 down vote accepted

This feature was present on old gnome2, but mising from latest gnome.Gnome power manager is supposed to give notification when battery is full, but it doesn't(It could be a bug). I couldn't find any option with dconf either.To me it appears that the only way to achieve this through a cron job which regulary checks whether battery is full or not.

First open terminal & type ls /proc/acpi/battery/. In my case, the output is C241. Your could be different(generally batt0 ot batt1).Also check the type of ac adapter,ls /proc/acpi/ac_adapter. Its C240 for me. Open gedit & copy the following script.

Remember to replace C241 & C240 with your battery type & ac adapter.


cd ~/.scripts
notification=$(grep 'notification:' notification|awk '{print $2}')

cd /proc/acpi/ac_adapter/C240;
power=$(grep 'state:' state|awk '{print $2}')


export DISPLAY=:0

if [ "$s1" = "on-line" ]; then
  cd /proc/acpi/battery/C241;
  state=$(grep 'charging state:' state|awk '{print $3}')
  if [ $state = $s2 ] && [ "$notification" = "$s4" ];
            notify-send  --urgency=critical "Power Manager" "battery is full" -i battery_full
            echo "notification: off" >~/.scripts/notification


  if [ $notification != "on" ]; then
    echo "notification: on" >~/.scripts/notification

save the file as at ~/.scripts (or anywhere you like). Make the file executable chmod a+x

On terminal type echo "notification: on" >~/.scripts/notification. Also add the same line at the end of your ~/.profile.

Install gnome-schedule (sudo apt-get install gnome-schedule).Launch it, choose new task & select "a task that launches recuurently". On command section put full path of the script file.In my case its ~/.scripts/ can set corn-job duration every min or every 5 apply.You can check running jobs by typing crontab -l in terminal.


You can run this script at every boot by adding gnome-schedule as a startup application(may not be required in your case).

Note: This is probably not the perfect way to do this, but it works.So far this much i can do with my little knowledge with bash scripting.I will improve the script if i find something better.

share|improve this answer
Try setting an envorinment variable(or even a file) when the battery is full, and when the battery starts depleting, reset it so that the notification can be retriggered when the battery is full again. – hexafraction Jun 14 '12 at 22:07
Initially that was my plan.I made system-wide variable like "export NOTIFICATION=on" & added to ~/.profile.But couldn't able to change(set /unset) that variable from bash script. Finally I created a separate file & read the data from there. – Khurshid Alam Jun 15 '12 at 13:30
thank you, it works after adding the notification file using echo "notification: on" >~/.scripts/notification – sohaibafifi Jun 15 '12 at 20:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.