#!/usr/bin/env sh battery=$1 print_battery_status() { battery_capacity=$(cat "/sys/class/power_supply/${battery}/capacity") \ || exit if [ "$battery_capacity" -lt 25 ]; then echo critical elif [ "$battery_capacity" -lt 50 ]; then echo low elif [ "$battery_capacity" -lt 75 ]; then echo medium elif [ "$battery_capacity" -lt 100 ]; then echo high else echo full fi } while :; do print_battery_status sleep 20 done