Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- VOLTAGE_FILE=${1:-"/sys/class/power_supply/hidpp_battery_1/voltage_now"}
- declare -A LEVELS
- LEVELS["4186"]="100"
- # 4156 99%
- # ... more shit
- LEVELS["35"]="0"
- VOLTAGE=`cat $VOLTAGE_FILE`
- VOLTAGE=${VOLTAGE::-3}
- for i in "${!LEVELS[@]}"
- do
- if [ "$VOLTAGE" -ge "$i" ]; then
- echo "$LEVELS[$i]"
- break
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment