I wanted to trigger an application based on the current status of the battery, so I wanted to get the information about the current battery charge status.
Its fairly simple in Linux. 'acpi' is very handy for the purpose. If you haven't installed it yet (you can check it using the code below):
For CentOS 6 users, the download link is here.
Here are some cool things you can do with acpi:
1. Check battey status
2. Check Battery Temperature
3. Check Battey Temperature ( in Fahrenheit )
4. Check power status
5. Show every device
Now that you have the information, you can play with it as you want. Here a simple bash script to get the battery information only:
Enjoy :)
Its fairly simple in Linux. 'acpi' is very handy for the purpose. If you haven't installed it yet (you can check it using the code below):
rpm -qa acpiYou can install it easily using apt-get in Ubuntu or if your machine is rpm based like mine, you can look for it in web.
For CentOS 6 users, the download link is here.
Here are some cool things you can do with acpi:
1. Check battey status
acpi
2. Check Battery Temperature
acpi -t
3. Check Battey Temperature ( in Fahrenheit )
acpi -t -f
4. Check power status
acpi -a
5. Show every device
acpi -V
Now that you have the information, you can play with it as you want. Here a simple bash script to get the battery information only:
#!/bin/bash
data=$(acpi)
battery=(${data//,/ })
echo ${battery[3]}
Enjoy :)
0 comments:
Post a Comment