-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathbattery-icon.sh
executable file
·61 lines (53 loc) · 1.66 KB
/
battery-icon.sh
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
# This script displays battery icon according to the charge level and charging state
# Author: Piotr Miller
# e-mail: [email protected]
# Website: http://nwg.pl
# Project: https://github.com/nwg-piotr/tint2-executors
# License: GPL3
# Dependencies: `acpi`
bat=$(acpi -b)
state=$(echo ${bat} | awk '{print $3}')
if [[ "$state" = "Not" ]]; then
level=$(echo ${bat} | awk '{print $5}')
level=${level::-1}
else
level=$(echo ${bat} | awk '{print $4}')
if [[ "$state" == *"Unknown"* ]]; then
level=${level::-1}
else
if [[ "$level" == "100%" ]]; then
level=${level::-1}
else
level=${level::-2}
fi
fi
fi
if [[ "$bat" == *"until"* ]]; then
if [[ "$level" -ge "95" ]]; then
echo ~/tint2-executors/images/bat-full-charging.svg
elif [[ "$level" -ge "75" ]]; then
echo ~/tint2-executors/images/bat-threefourth-charging.svg
elif [[ "$level" -ge "35" ]]; then
echo ~/tint2-executors/images/bat-half-charging.svg
elif [[ "$level" -ge "15" ]]; then
echo ~/tint2-executors/images/bat-quarter-charging.svg
else
echo ~/tint2-executors/images/bat-empty-charging.svg
fi
else
if [[ "$level" -ge "95" ]]; then
echo ~/tint2-executors/images/bat-full.svg
elif [[ "$level" -ge "75" ]]; then
echo ~/tint2-executors/images/bat-threefourth.svg
elif [[ "$level" -ge "35" ]]; then
echo ~/tint2-executors/images/bat-half.svg
elif [[ "$level" -ge "15" ]]; then
echo ~/tint2-executors/images/bat-quarter.svg
else
echo ~/tint2-executors/images/bat-empty.svg
fi
fi
if [[ $1 = "-l" ]]; then
echo ${level}%
fi