Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/battery_percentage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ print_battery_percentage() {
fi
local percentage=$(upower -i $battery | awk '/percentage:/ {print $2}')
if [ "$percentage" ]; then
echo ${percentage%.*%}
echo "$(float2int $percentage)%"
return
fi
local energy
Expand Down
11 changes: 11 additions & 0 deletions scripts/helpers.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ battery_status() {
fi
fi
}

float2int() {
local float="$1"
if [[ $float =~ "," ]]; then
echo ${float%,*}
elif [[ $float =~ "." ]]; then
echo ${float%.*}
else
echo ${float//%}
fi
}