Minor changes
This commit is contained in:
parent
3e36fb9979
commit
d743042a70
@ -1,4 +1,4 @@
|
||||
#/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
# battery-monitor.sh
|
||||
|
||||
@ -24,9 +24,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# To do. Add code to verify that the user is root or has run the script with
|
||||
# sudo. Add code to verify that the bc program is installed.
|
||||
|
||||
# Change this variable to the group that should be informed of a need to
|
||||
# charge the battery. On GNU/Linux distributions users are often part of
|
||||
# a group that is the same as their login name, which works well if you only
|
||||
@ -38,13 +35,13 @@ group="scm"
|
||||
|
||||
battery="BAT0"
|
||||
|
||||
# If the battery is fully charged.
|
||||
# If the battery is fully charged, exit the program.
|
||||
|
||||
if (( minutes == 0 )); then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Calculate the state of the battery.
|
||||
# Calculate the number of minutes that the battery has left.
|
||||
|
||||
charge=$(cat /sys/class/power_supply/$battery/charge_now)
|
||||
discharge=$(cat /sys/class/power_supply/$battery/current_now)
|
||||
@ -58,14 +55,12 @@ minutes=$(echo "scale=2; $hours * 60" | bc -l)
|
||||
# battery-status.sh script to aid in my understanding of what was going on,
|
||||
# and I discovered a variance of minutes plus/minus each time that I ran it,
|
||||
# so the system is clearly making an estimate. Keep this in mind when setting
|
||||
# the minimum value.
|
||||
|
||||
# Change this variable to you liking, but less than 40.00 is likely a bad
|
||||
# idea. YOU'VE BEEN WARNED!
|
||||
# the minimum value. Less than 40.00 is likely a bad idea. YOU'VE BEEN
|
||||
# WARNED!
|
||||
|
||||
minimum=40.00
|
||||
|
||||
If the minutes of charge are less than the minimum.
|
||||
# If the minutes of charge are less than the minimum, suspend the computer.
|
||||
|
||||
if (( $(echo "$minutes < $minimum" | bc -l) )); then
|
||||
echo "Suspending the computer! Battery charge is needed!" | wall -g $group
|
||||
|
Loading…
x
Reference in New Issue
Block a user