Audio low battery alarm (SOLVED)

Write suggestions and new ideas in here
More ideas here http://community.linuxmint.com/idea/welcome
Forum rules
  • Only post ideas here that are specifically about the Linux Mint distribution or its websites.
  • So that developers and users from any distribution can discuss ideas in one place, post ideas about improving software to the collaboration website for that software instead.
Post Reply
User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Audio low battery alarm (SOLVED)

Post by lyndave » Sat Mar 11, 2017 10:52 am

a low level battery alarm that makes an audio sound would be a great addition to linux mint
this alarm could be set at a level specified by the user (10 or 20 %) any level the user chooses.
it would be great if the user could choose any wav or mp3 files from their computer for the alarm sound.
i have done a lot of searching online for such an alarm and cannot find one, however their seems to be a need for such a device
Last edited by lyndave on Mon Apr 03, 2017 10:31 pm, edited 1 time in total.

User avatar
jimallyn
Level 18
Level 18
Posts: 8469
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Audio low battery alarm

Post by jimallyn » Sat Mar 11, 2017 11:03 pm

That shouldn't be too hard to write a script or program for. Either the acpi command or the upower command will give you the battery state. You could pipe the output through grep to pick out the line that has the information you want, then compare that with your desired alarm level, and either play a sound or not, depending on the level. I don't have a laptop here at the moment, so not able to play with this right now. I wouldn't be surprised if somebody pops in here to tell you how to do it, or maybe somebody will throw together a short script to do this.

Have a look at these pages:

https://www.cyberciti.biz/faq/linux-lap ... mperature/

http://askubuntu.com/questions/69556/ho ... g-terminal

https://www.cyberciti.biz/faq/linux-che ... ry-status/

https://www.ostechnix.com/how-to-check- ... -in-linux/
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Re: Audio low battery alarm

Post by lyndave » Sun Mar 12, 2017 4:05 am

i dont have enough experience to make a script for this sadly

User avatar
jimallyn
Level 18
Level 18
Posts: 8469
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Audio low battery alarm

Post by jimallyn » Sun Mar 12, 2017 8:40 pm

I might be able to pull it all together, but it would be a bit of a learning experience for me, and I'm not sure I have the time to wade through all that right now. There are probably people on these forums that could whip out a one-liner script to do that in their sleep. But not me. I'd have to work at it.
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Re: Audio low battery alarm

Post by lyndave » Mon Mar 13, 2017 10:40 am

jimallyn

i would like it if you could have a go at it, but no hurry, and thankyou for your interest

User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Re: Audio low battery alarm

Post by lyndave » Wed Mar 15, 2017 9:24 pm

jimallyn

i found this script for a low level alarm, perhaps this is something that could be put into the next version of mint


This is a script i found online after a lot of research, i changed the mp3 file to suite myself and i also changed the % that triggers the alarm.
i set the script up in cron -e
i also put the mp3 in Home
Then i tested it

To get mpg123 and be able to play audio:

sudo apt-get install acpi mpg123

File to open to write the command:

crontab -e

Command to enter at end of the file:


*/1 * * * * if [ `acpi -b | awk ' { print ( $(NF-2)-0)}'` -lt "60" ] ; then mpg123 /home/dave/alarm.mp3 ; fi

its a very simple script, however it does exactly what i require

User avatar
jimallyn
Level 18
Level 18
Posts: 8469
Joined: Thu Jun 05, 2014 7:34 pm
Location: Wenatchee, WA USA

Re: Audio low battery alarm

Post by jimallyn » Thu Mar 16, 2017 1:48 am

Cool, lyndave. I may copy that and use it whenever I do Linux installs on laptops. I knew somebody that knew what they were doing could do that in a one-liner. But not me!
Image

“If the government were coming for your TVs and cars, then you'd be upset. But, as it is, they're only coming for your sons.” - Daniel Berrigan

User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Re: Audio low battery alarm

Post by lyndave » Thu Mar 16, 2017 11:18 am

jimallyn

i just found a problem with the script :(
it seems once the script activates, the sound file starts and i can't shut it off,
even when the power level gets above the preset %
So i guess its back to the drawing board.
not happy..... :x
so i guess i will keep on looking for a script

User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Re: Audio low battery alarm

Post by lyndave » Sat Mar 18, 2017 11:45 am

i have not been able to find or create a low level battery alarm with audio however i did come across a low/high level alarm that gives a pop up when the battery is either low or high, so i wouldn't say this was solved. however if anyone would like to have a look at the alarm i found the url is http://linuxsoftware.moncerbae.com/2015 ... buntu.html although it says ubuntu in the address, its for Linux mint as well

User avatar
lyndave
Level 1
Level 1
Posts: 44
Joined: Tue Feb 07, 2017 12:30 pm
Location: australia

Re: Audio low battery alarm

Post by lyndave » Sun Apr 02, 2017 10:55 am

i have worked on the low level battery alarm with audio and have come up
with a work about,it's not exactly what i wanted however it serves the purpose that i wanted.
What i have done is this.
Step 1 sudo apt-get install acpi
Step 2 i went to http://linuxsoftware.moncerbae.com/2015 ... buntu.html
and followed the instructions
Step 3 i went to sound settings/soundeffects and chose the sound i wanted under notifications.
After doing the above, the sounds goes off once the battery gets below 25% or above 95%


PROBLEM SOLVED :)

gvsa123
Level 1
Level 1
Posts: 2
Joined: Sun Jun 24, 2018 11:16 am

Re: Audio low battery alarm

Post by gvsa123 » Thu Oct 18, 2018 7:50 pm

lyndave wrote:
Wed Mar 15, 2017 9:24 pm


To get mpg123 and be able to play audio:

sudo apt-get install acpi mpg123

File to open to write the command:

crontab -e

Command to enter at end of the file:


*/1 * * * * if [ `acpi -b | awk ' { print ( $(NF-2)-0)}'` -lt "60" ] ; then mpg123 /home/dave/alarm.mp3 ; fi

its a very simple script, however it does exactly what i require
Would you mind breaking down what you did there for the people not familiar but interested in understanding the script. I found asking questions like this helps me understand linux and coding in general better. Thanks.

User avatar
Pierre
Level 17
Level 17
Posts: 7569
Joined: Fri Sep 05, 2008 5:33 am
Location: Perth, AU.

Re: Audio low battery alarm (SOLVED)

Post by Pierre » Thu Oct 18, 2018 10:55 pm

the original poster will be unlikely to reply,
as this is an older post, that is no longer active.

you may be better off, if you instead start another, New Post, about your Script Query.
Image
Please edit your original post title to include [SOLVED] - when your problem is solved!
and DO LOOK at those Unanswered Topics - - you may be able to answer some!.

Post Reply

Return to “Suggestions & New Ideas”