Add support for time remaining to battery when charging in linux.
This commit is contained in:
parent
f7599e9564
commit
11d539ec77
@ -14,6 +14,11 @@ function generate_battery_update {
|
|||||||
local battery_percentage=$(grep 'percentage:' <<<"$battery_status" | awk '{print $2}')
|
local battery_percentage=$(grep 'percentage:' <<<"$battery_status" | awk '{print $2}')
|
||||||
battery_percentage=${battery_percentage%\%}
|
battery_percentage=${battery_percentage%\%}
|
||||||
local time_remaining=$(grep 'time to empty:' <<<"$battery_status" | sed 's/\W*time to empty:\W*//g')
|
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 battery_icon=""
|
||||||
local class=""
|
local class=""
|
||||||
|
|
||||||
@ -45,7 +50,7 @@ function generate_battery_update {
|
|||||||
jq --unbuffered --compact-output <<EOF
|
jq --unbuffered --compact-output <<EOF
|
||||||
{
|
{
|
||||||
"text":"${battery_percentage}% ${battery_icon}",
|
"text":"${battery_percentage}% ${battery_icon}",
|
||||||
"tooltip":"$time_remaining",
|
"tooltip":"$tooltip",
|
||||||
"percentage":${battery_percentage},
|
"percentage":${battery_percentage},
|
||||||
"class":"${class}"
|
"class":"${class}"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user