Hibernation? + battery widget fix for framework 12
This commit is contained in:
parent
cc32b7c14f
commit
873a9c562b
4 changed files with 47 additions and 13 deletions
|
|
@ -6,7 +6,12 @@
|
|||
battery-path = "/sys/class/power_supply/${
|
||||
if hwconfig.hostname == "kylekrein-mac"
|
||||
then "macsmc-battery"
|
||||
else "BAT0"
|
||||
else
|
||||
(
|
||||
if hwconfig.hostname == "kylekrein-framework12"
|
||||
then "BAT1"
|
||||
else "BAT0"
|
||||
)
|
||||
}";
|
||||
get-battery-level = "${pkgs.writeShellScriptBin "get-battery-level" ''
|
||||
cat ${battery-path}/capacity 2>/dev/null || echo "N/A"
|
||||
|
|
@ -60,11 +65,27 @@
|
|||
echo "$ICON"
|
||||
''}/bin/get-icon";
|
||||
get-remaining-time = "${pkgs.writeShellScriptBin "get-remaining-time" ''
|
||||
REMAINING_ENERGY=$(cat ${battery-path}/energy_now)
|
||||
POWER_USAGE=$(cat ${battery-path}/power_now)
|
||||
REMAINING_ENERGY=$(cat ${battery-path}/${
|
||||
if hwconfig == "kylekrein-mac"
|
||||
then "energy_now"
|
||||
else "charge_now"
|
||||
})
|
||||
POWER_USAGE=$(cat ${battery-path}/${
|
||||
if hwconfig.hostname == "kylekrein-mac"
|
||||
then "power_now"
|
||||
else "current_now"
|
||||
})
|
||||
if [[ -n "$REMAINING_ENERGY" && -n "$POWER_USAGE" && "$POWER_USAGE" -ne 0 ]]; then
|
||||
TIME_LEFT=$((0 - (REMAINING_ENERGY / POWER_USAGE)))
|
||||
MINUTES_LEFT=$(((0 - ( (REMAINING_ENERGY * 60) / POWER_USAGE )) - (TIME_LEFT * 60)))
|
||||
TIME_LEFT=$((${
|
||||
if hwconfig.hostname == "kylekrein-mac"
|
||||
then "0 - "
|
||||
else ""
|
||||
}(REMAINING_ENERGY / POWER_USAGE)))
|
||||
MINUTES_LEFT=$(((${
|
||||
if hwconfig.hostname == "kylekrein-mac"
|
||||
then "0 - "
|
||||
else ""
|
||||
}( (REMAINING_ENERGY * 60) / POWER_USAGE )) - (TIME_LEFT * 60)))
|
||||
echo "$TIME_LEFT h $MINUTES_LEFT min"
|
||||
else
|
||||
echo ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue