summaryrefslogtreecommitdiff
path: root/.config/eww/scripts/battery
blob: 071f0e9af8628b2d3eb1d6f5152f59da737c41f1 (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
38
#!/bin/sh

set -e

cd /sys/class/power_supply/BAT1

awk '
	FILENAME == "capacity" {
		val = $0
		printf "percentage=%d%%\n", val
	}

	FILENAME == "status" {
		printf "icon="
		if ($0 == "Charging")
			print "󰂄"
		else if (val >= 90)
			print "󰁹"
		else if (val >= 80)
			print "󰂂"
		else if (val >= 70)
			print "󰂁"
		else if (val >= 60)
			print "󰁿"
		else if (val >= 50)
			print "󰁾"
		else if (val >= 40)
			print "󰁽"
		else if (val >= 30)
			print "󰁼"
		else if (val >= 20)
			print "󰁻"
		else if (val >= 10)
			print "󰁺"
		else
			print "󰂎"
	}' capacity status \
	| jo