-
Notifications
You must be signed in to change notification settings - Fork 1
/
formatter
executable file
·92 lines (67 loc) · 2.14 KB
/
formatter
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
. ~/ui/lemonbar/variables
while read -r line; do
case $line in
B*)
battery_lvl="$(echo ${line} | cut -d' ' -f4 | rev | cut -c 3- | rev)"
if [[ $battery_lvl -lt 10 ]]; then
battery_clr=$battery_exlow
elif [[ $battery_lvl -lt 25 ]]; then
battery_clr=$battery_vlow
elif [[ $battery_lvl -lt 50 ]]; then
battery_clr=$battery_low
elif [[ $battery_lvl -lt 75 ]]; then
battery_clr=$battery_good
elif [[ $battery_lvl -lt 95 ]]; then
battery_clr=$battery_high
else
battery_clr=$battery_full
fi
if [[ $battery_lvl -lt 20 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 30 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 40 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 50 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 60 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 70 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 80 ]]; then
battery_ico=""
elif [[ $battery_lvl -lt 90 ]]; then
battery_ico=""
else
battery_ico=""
fi
if [[ $battery_lvl -lt 10 ]]; then
ac="%{F$main_bg}%{B$battery_clr}"
else
ac="%{F$battery_clr}%{B-}"
fi
ac_status="$(echo ${line} | cut -d' ' -f3)"
if [[ "$ac_status" == "C"* ]]; then
ac="%{F$ac_clr}"
if [[ $battery_lvl -lt 95 ]]; then
ac="${ac}%{F$battery_clr}"
else
ac="${ac}%{F$main_bg}%{B$battery_clr}"
fi
fi
battery_info="$(echo ${line} | cut -d' ' -f4-5 | sed 's/,//g')"
battery="%{T2}${ac}%{T} %{T2}${battery_ico}%{T} ${battery_info//%/%%} %{F-}%{B-}"
;;
T*)
date=${line%' '*}
current_time=${line##*' '}
datetime="%{T2}%{T} ${date:1} %{T2}%{T} %{F$main_bg}00:00:00 %{F-}"
;;
W*)
workspaces=${line%%','*}
layout=${line#*','}
;;
esac
printf "%s\n" "%{l}%{B#427b58}%{F#8ec07c} %{T2}%{T} %{F-}%{B-} ${layout}%{c}${workspaces:1}%{r}$battery $datetime%{r}$current_time "
done