Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- BAT='/sys/class/power_supply/BAT1'
- STATUS_DISCH='Discharging'
- LOW='15'
- while [ 0 ]; do
- bat_status=`cat ${BAT}/status`
- if [[ ${bat_status} == ${STATUS_DISCH} ]]; then
- bat_current=`cat ${BAT}/charge_now`
- bat_full=`cat ${BAT}/charge_full`
- bat_perc=`echo "${bat_current} / ${bat_full} * 100" | bc -l | head -c 6 | tr '.' ','`
- if [[ ${bat_perc} < ${LOW} ]]; then
- bat_perc_format=`printf '%.4lg\n' ${bat_perc}`
- notify-send "Battery low: ${bat_perc_format}%"
- fi
- sleep 120
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement