00_lowpower.sh 452 B

123456789101112131415
  1. #!/bin/bash
  2. BAT_PNT=$(upower -i "$(upower -e | grep 'battery')" | grep -E "state|to\ full|percentage" | awk '/perc/{print $2}' | cut -d % -f1 )
  3. if [ "$BAT_PNT" -lt "20" ]; then
  4. if [ "$BAT_PNT" -lt "5" ]; then
  5. echo '{"type":"once","content":"Low Battery: 5% of battery remaining"}'
  6. elif [ "$BAT_PNT" -lt "10" ]; then
  7. echo '{"type":"once","content":"Low Battery: 10% of battery remaining"}'
  8. fi
  9. else
  10. echo "$BAT_PNT"
  11. fi