From 11d539ec7745e6f3313bb68c53bb79904aa6c9f7 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 14 Nov 2022 22:35:53 -0500 Subject: [PATCH] Add support for time remaining to battery when charging in linux. --- ansible/roles/sway/files/waybar_battery_linux.bash | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ansible/roles/sway/files/waybar_battery_linux.bash b/ansible/roles/sway/files/waybar_battery_linux.bash index 9b4ffea..811609c 100644 --- a/ansible/roles/sway/files/waybar_battery_linux.bash +++ b/ansible/roles/sway/files/waybar_battery_linux.bash @@ -14,6 +14,11 @@ function generate_battery_update { local battery_percentage=$(grep 'percentage:' <<<"$battery_status" | awk '{print $2}') battery_percentage=${battery_percentage%\%} local time_remaining=$(grep 'time to empty:' <<<"$battery_status" | sed 's/\W*time to empty:\W*//g') + local tooltip="$time_remaining until empty" + if [ -z "$time_remaining" ]; then + time_remaining=$(grep 'time to full:' <<<"$battery_status" | sed 's/\W*time to full:\W*//g') + tooltip="$time_remaining until full" + fi local battery_icon="" local class="" @@ -45,7 +50,7 @@ function generate_battery_update { jq --unbuffered --compact-output <