bat_files="/sys/class/power_supply/BAT0" bat_status=$(cat ${bat_files}/status) capacity=$(cat "${bat_files}/capacity") function set_capacity() { if [[ ${capacity} -lt 10 ]]; then cap=0 elif [[ ${capacity} -lt 20 ]]; then cap=10 elif [[ ${capacity} -lt 30 ]]; then cap=20 elif [[ ${capacity} -lt 40 ]]; then cap=30 elif [[ ${capacity} -lt 50 ]]; then cap=40 elif [[ ${capacity} -lt 60 ]]; then cap=50 elif [[ ${capacity} -lt 70 ]]; then cap=60 elif [[ ${capacity} -lt 80 ]]; then cap=70 elif [[ ${capacity} -lt 90 ]]; then cap=80 elif [[ ${capacity} -lt 100 ]]; then cap=90 else cap=100 fi }