summaryrefslogtreecommitdiff
path: root/.config/eww/scripts/battery
blob: 0db4adb216cc8f4bc5608a9aa14abdc2fa586d2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh

set -e

acpi | awk '
	{
		sub(/Battery [0-9]+: /, "")
		FS = "[, ]+"
		n = NF
		sub(/%$/, "", $n)
		printf "percentage=%d%%\n", $n
		printf "icon="
		$n = int($n)
		if ($1 == "Charging")
			print "󰂄"
		else if ($n >= 90)
			print "󰁹"
		else if ($n >= 80)
			print "󰂂"
		else if ($n >= 70)
			print "󰂁"
		else if ($n >= 60)
			print "󰁿"
		else if ($n >= 50)
			print "󰁾"
		else if ($n >= 40)
			print "󰁽"
		else if ($n >= 30)
			print "󰁼"
		else if ($n >= 20)
			print "󰁻"
		else if ($n >= 10)
			print "󰁺"
		else
			print "󰂎"
	}' \
	| jo