#!/bin/bash

perc=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep percentage | awk -F: '{print $2}' | xargs)
state=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep state | awk -F: '{print $2}' | xargs)

num=$(echo ${perc::-1})

if [ $state == "charging" ]; then
	echo "󰂄 ${perc}"
else
	#echo "󰁹 ${perc}"

	if [ $num -gt 95 ]; then
		echo "󰁹 ${perc}"
	elif [ $num -gt 90 ]; then
		echo "󰂂 ${perc}"
	elif [ $num -gt 80 ]; then
		echo "󰂁 ${perc}"
	elif [ $num -gt 70 ]; then
		echo "󰂀 ${perc}"
	elif [ $num -gt 60 ]; then
		echo "󰁿 ${perc}"
	elif [ $num -gt 50 ]; then
		echo "󰁾 ${perc}"
	elif [ $num -gt 40 ]; then
		echo "󰁽 ${perc}"
	elif [ $num -gt 30 ]; then
		echo "󰁼 ${perc}"
	elif [ $num -gt 20 ]; then
		echo "󰁻 ${perc}"
	elif [ $num -gt 10 ]; then
		echo "󰁺 ${perc}"
	else
		notify-send --urgency=critical -t 2000 "󱃍 low battery, please charge"
		echo "󰂎 ${perc}"
	fi
fi
