LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-01-2014, 08:10 AM   #1
marchelloUA
LQ Newbie
 
Registered: Nov 2014
Posts: 27

Rep: Reputation: Disabled
Question show pop-up each minute when battery is 100% charged


Hi all,

How do I show pop-up each minute when battery is 100% charged? Maybe even with some sound...

It does show pop-up only once. I can miss it easily. I'd like to know when it is time to unplug charger in time.

How do I perform it?
Thanks ahead.

Ubuntu 14.04.1 LTS
 
Old 12-01-2014, 09:08 AM   #2
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 4,462

Rep: Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369Reputation: 1369
The battery percentage charge is likely to be found in /sys/class/power_supply/BAT0/capacity.
Popup messages can be created using 'xmessage'.
Sounds can be played using 'aplay'.
Regular checks can be scheduled using 'cron'.

i.e. Write a script that can be run as a cron job.
 
Old 12-01-2014, 11:05 AM   #3
marchelloUA
LQ Newbie
 
Registered: Nov 2014
Posts: 27

Original Poster
Rep: Reputation: Disabled
Question

Quote:
Originally Posted by allend View Post
The battery percentage charge is likely to be found in /sys/class/power_supply/BAT0/capacity.
Popup messages can be created using 'xmessage'.
Sounds can be played using 'aplay'.
Regular checks can be scheduled using 'cron'.

i.e. Write a script that can be run as a cron job.

Tried to do it in python, can someone please comment where is my error ?

Code:
Python 3.4.0 (default, Apr 11 2014, 13:05:18) 
[GCC 4.8.2] on linux
Type "copyright", "credits" or "license()" for more information.
>>> fh = open("/sys/class/power_supply/BAT0/capacity", "r")
>>> lines = [ i.rstrip() for i in fh.readlines()]
>>> print lines[2]
SyntaxError: invalid syntax
>>>
 
Old 12-01-2014, 12:20 PM   #4
marchelloUA
LQ Newbie
 
Registered: Nov 2014
Posts: 27

Original Poster
Rep: Reputation: Disabled
Smile

My actual bash version:

Code:
#!/bin/sh
valuea=`cat /sys/class/power_supply/BAT0/capacity`
echo "$valuea"
if [ $valuea -eq "98" ] || [ $valuea -eq "99" ] || [ $valuea -eq "100" ] || [ $valuea -eq "97" ]
then 
  echo "please unplug charger"
#  xmessage "please unplug charger"
  aplay /home/ymarkiv/Dropbox/music/wav/animals131.wav
  xmessage "please unplug charger"
else 
  echo "still charging"
#  xmessage "still charging"
fi
exit
power_100.sh (END)
 
  


Reply

Tags
battery


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Cron Job Error Show the Following 24: bad minute JockVSJock Programming 2 09-15-2013 02:57 PM
How to show zenity pop up box on remote system unclesamcrazy Linux - Newbie 5 06-13-2013 03:07 AM
how to show emergency pop up message to user? (on X) browny_amiga Linux - General 26 11-08-2011 05:36 AM
notebook battery doesn't charge to 100% pusrob Linux - Hardware 7 07-02-2011 04:50 AM
Battery status tools report >100% remaining hollywoodb Linux - Laptop and Netbook 0 06-22-2009 04:30 PM


All times are GMT -5. The time now is 02:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration