Skip to content

Instantly share code, notes, and snippets.

@tvorogme
Created February 24, 2018 14:34
Show Gist options
  • Save tvorogme/88030e4ff555b6697d76bfef2b53d7e1 to your computer and use it in GitHub Desktop.
Save tvorogme/88030e4ff555b6697d76bfef2b53d7e1 to your computer and use it in GitHub Desktop.
#! /bin/bash
SLEEP_TIME=5 # Default time between checks.
SAFE_PERCENT=30 # Still safe at this level.
DANGER_PERCENT=20 # Warn when battery at this level.
CRITICAL_PERCENT=5 # Hibernate when battery at this level.
NAGBAR_PID=0
export DISPLAY=:0.0
while [ true ]; do
if [[ -n $(acpi -b | grep -i discharging) ]]; then
rem_bat=$(acpi -b | grep -Eo "[0-9]+%" | grep -Eo "[0-9]+")
if [[ $rem_bat -gt $SAFE_PERCENT ]]; then
SLEEP_TIME=10
else
SLEEP_TIME=5
if [[ $rem_bat -le $DANGER_PERCENT ]]; then
SLEEP_TIME=2
twmnc -c "Батарея садится"
fi
fi
else
SLEEP_TIME=10
fi
sleep ${SLEEP_TIME}m
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment