File tree Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Expand file tree Collapse file tree 2 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ battery_discharging() {
15
15
[[ $status =~ (discharging) ]]
16
16
}
17
17
18
+ battery_charged () {
19
+ local status=" $( battery_status) "
20
+ [[ $status =~ (charged) ]]
21
+ }
22
+
18
23
pmset_battery_remaining_time () {
19
24
local status=" $( pmset -g batt) "
20
25
if echo $status | grep ' no estimate' > /dev/null 2>&1 ; then
@@ -31,8 +36,16 @@ pmset_battery_remaining_time() {
31
36
else
32
37
echo $remaining_time | awk ' {printf "- %s left", $1}'
33
38
fi
39
+ elif battery_charged; then
40
+ if $short ; then
41
+ echo $remaining_time | awk ' {printf "charged", $1}'
42
+ else
43
+ echo $remaining_time | awk ' {printf "fully charged", $1}'
44
+ fi
34
45
else
35
- if ! $short ; then
46
+ if $short ; then
47
+ echo $remaining_time | awk ' {printf "~%s", $1}'
48
+ else
36
49
echo $remaining_time | awk ' {printf "- %s till full", $1}'
37
50
fi
38
51
fi
@@ -76,9 +89,7 @@ main() {
76
89
if battery_discharging; then
77
90
print_battery_remain
78
91
else
79
- if ! $short ; then
80
- print_battery_full
81
- fi
92
+ print_battery_full
82
93
fi
83
94
}
84
95
main
Original file line number Diff line number Diff line change @@ -8,23 +8,29 @@ color_full_charge_default="#[fg=green]"
8
8
color_high_charge_default=" #[fg=yellow]"
9
9
color_medium_charge_default=" #[fg=colour208]" # orange
10
10
color_low_charge_default=" #[fg=red]"
11
+ color_charging_default=" #[fg=green]"
11
12
12
13
color_full_charge=" "
13
14
color_high_charge=" "
14
15
color_medium_charge=" "
15
16
color_low_charge=" "
17
+ color_charging=" "
16
18
17
19
get_charge_color_settings () {
18
20
color_full_charge=$( get_tmux_option " @batt_color_full_charge" " $color_full_charge_default " )
19
21
color_high_charge=$( get_tmux_option " @batt_color_high_charge" " $color_high_charge_default " )
20
22
color_medium_charge=$( get_tmux_option " @batt_color_medium_charge" " $color_medium_charge_default " )
21
23
color_low_charge=$( get_tmux_option " @batt_color_low_charge" " $color_low_charge_default " )
24
+ color_charging=$( get_tmux_option " @batt_color_charging" " $color_charging_default " )
22
25
}
23
26
24
27
print_battery_status_fg () {
25
28
# Call `battery_percentage.sh`.
26
29
percentage=$( $CURRENT_DIR /battery_percentage.sh | sed -e ' s/%//' )
27
- if [ $percentage -eq 100 ]; then
30
+ status=$( battery_status | awk ' {print $1;}' )
31
+ if [ $status == ' charging' ]; then
32
+ printf $color_charging
33
+ elif [ $percentage -eq 100 ]; then
28
34
printf $color_full_charge
29
35
elif [ $percentage -le 99 -a $percentage -ge 51 ]; then
30
36
printf $color_high_charge
You can’t perform that action at this time.
0 commit comments