LINUX.ORG.RU

История изменений

Исправление sudoapter, (текущая версия) :

exec 2>&1
INTERVAL=60 # in seconds
battery20charge=20

while true; do
  if [ ! "$(cat /sys/class/power_supply/BAT0/status)" = "Full" ]; then
    battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
    if [ "${battery_level}" -le "10" ]; then
      notify-send "Battery very low" "Battery level is ${battery_level}%! Suspending system in 1 minute."
      sleep 60
      zzz -z
    elif [ "${battery_level}" -le "$battery20charge" ]; then
      let battery20charge--
      notify-send "Battery low" "Battery level is ${battery_level}%!"
    fi
  fi
  sleep ${INTERVAL}
done

Исходная версия sudoapter, :

exec 2>&1
INTERVAL=60 # in seconds
battery20charge=20

while true; do
  if [ ! "$(cat /sys/class/power_supply/BAT0/status)" = "Full" ]; then
    battery_level=$(cat /sys/class/power_supply/BAT0/capacity)
    if [ "${battery_level}" -le "10" ]; then
      notify-send "Battery very low" "Battery level is ${battery_level}%! Suspending system in 1 minute."
      sleep 60
      zzz -z
    elif [ "${battery_level}" -le "$battery20charge" ]; then
      let battery20charge--
      notify-send "Battery low" "Battery level is ${battery_level}%!"
    fi
  fi
sleep ${INTERVAL}
done