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 ""
|
||||
|
|
|
|||
|
|
@ -19,13 +19,9 @@
|
|||
(import ../../modules/libvirt/user.nix {username = "kylekrein";})
|
||||
|
||||
../../users/tania
|
||||
|
||||
./hibernation.nix
|
||||
];
|
||||
boot = {
|
||||
# kernelParams = [
|
||||
# "resume_offset=YOUR_OFFSET"
|
||||
# ];
|
||||
# resumeDevice = "/dev/disk/by-label/nixos";
|
||||
};
|
||||
|
||||
sops.secrets."ssh_keys/${hwconfig.hostname}" = {};
|
||||
services.fwupd.enable = true; #fwupdmgr update
|
||||
|
|
|
|||
18
nixos/hosts/kylekrein-framework12/hibernation.nix
Normal file
18
nixos/hosts/kylekrein-framework12/hibernation.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
{pkgs, ...}: {
|
||||
boot = {
|
||||
kernelParams = [
|
||||
"resume_offset=533760"
|
||||
"mem_sleep_default=deep"
|
||||
];
|
||||
resumeDevice = "/dev/disk/by-label/nixos";
|
||||
};
|
||||
services.logind = {
|
||||
lidSwitch = "suspend-then-hibernate";
|
||||
powerKey = "suspend-then-hibernate";
|
||||
powerKeyLongPress = "poweroff";
|
||||
};
|
||||
systemd.sleep.extraConfig = ''
|
||||
HibernateDelaySec=30m
|
||||
SuspendState=mem
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue