Skip to content

Commit 8cb3cce

Browse files
mys721txmartinbeentjes
authored andcommitted
Adding status_bg for charging (#71)
a follow-up to #68. The background color is added for charging status.
1 parent c2cd5c8 commit 8cb3cce

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/battery_status_bg.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,35 @@ color_full_charge_default="#[bg=green]"
88
color_high_charge_default="#[bg=yellow]"
99
color_medium_charge_default="#[bg=colour208]" # orange
1010
color_low_charge_default="#[bg=red]"
11+
color_charging_default="#[bg=green]"
1112

1213
color_full_charge=""
1314
color_high_charge=""
1415
color_medium_charge=""
1516
color_low_charge=""
17+
color_charging=""
1618

1719
get_charge_color_settings() {
1820
color_full_charge=$(get_tmux_option "@batt_color_full_charge" "$color_full_charge_default")
1921
color_high_charge=$(get_tmux_option "@batt_color_high_charge" "$color_high_charge_default")
2022
color_medium_charge=$(get_tmux_option "@batt_color_medium_charge" "$color_medium_charge_default")
2123
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")
2225
}
2326

2427
print_battery_status_bg() {
2528
# Call `battery_percentage.sh`.
2629
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
2834
printf $color_full_charge
2935
elif [ $percentage -le 99 -a $percentage -ge 51 ];then
3036
printf $color_high_charge
3137
elif [ $percentage -le 50 -a $percentage -ge 16 ];then
3238
printf $color_medium_charge
33-
elif [ "$percentage" == "" ];then
39+
elif [ "$percentage" == "" ];then
3440
printf $color_full_charge_default # assume it's a desktop
3541
else
3642
printf $color_low_charge

0 commit comments

Comments
 (0)