From 56a7d5302bc8aed97bcdbad06496464dc2f6ff4d Mon Sep 17 00:00:00 2001 From: slange-dev <74963785+slange-dev@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:15:20 +0100 Subject: [PATCH] Update helpers.sh Add pull request #89 - Fix battery percentage output when using upower ( https://github.com/tmux-plugins/tmux-battery/pull/89 ) --- scripts/helpers.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/helpers.sh b/scripts/helpers.sh index 270e688..a547e0c 100644 --- a/scripts/helpers.sh +++ b/scripts/helpers.sh @@ -61,3 +61,14 @@ battery_status() { fi fi } + +float2int() { + local float="$1" + if [[ $float =~ "," ]]; then + echo ${float%,*} + elif [[ $float =~ "." ]]; then + echo ${float%.*} + else + echo ${float//%} + fi +}