Skip to content

Commit d375f64

Browse files
Add option to display battery status as hearts in battery.sh
1 parent ba893c9 commit d375f64

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

segments/battery.sh

+17
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ run_segment() {
3939
"cute")
4040
output=$(__cutinate "$battery_status")
4141
;;
42+
"hearts")
43+
output=$(__generate_hearts "$battery_status")
4244
esac
4345
if [ -n "$output" ]; then
4446
echo "$output"
@@ -134,6 +136,21 @@ __cutinate() {
134136
done
135137
}
136138

139+
__generate_hearts() {
140+
perc=$1
141+
num_hearts=$TMUX_POWERLINE_SEG_BATTERY_NUM_HEARTS
142+
hearts_output=""
143+
144+
for i in $(seq 1 "$num_hearts"); do
145+
if [ "$perc" -ge $((i * 100 / num_hearts)) ]; then
146+
hearts_output+="$BATTERY_FULL "
147+
else
148+
hearts_output+="$BATTERY_EMPTY "
149+
fi
150+
done
151+
echo "$hearts_output"
152+
}
153+
137154
__linux_get_bat() {
138155
bf=$(cat "$BAT_FULL")
139156
bn=$(cat "$BAT_NOW")

0 commit comments

Comments
 (0)