17 lines
650 B
Nix
17 lines
650 B
Nix
|
{ pkgs, ... }:
|
||
|
{
|
||
|
home.packages = [
|
||
|
(pkgs.writeShellScriptBin "battery-status" ''
|
||
|
status=$(${pkgs.acpi}/bin/acpi)
|
||
|
bat_name=$(echo "$status" | grep -o -e "^[Aa-Zz]*\s[0-9]:")
|
||
|
bat_status=$(echo $status | grep -o -e "[A-Z][a-z]*," | sed "s/,//")
|
||
|
bat_pct=$(echo $status | grep -o -e "[0-9]*%")
|
||
|
bat_time=$(echo $status | grep -o -e "[0-9]*:[0-9]*:[0-9]* [a-z].*")
|
||
|
power=$(cat /sys/class/power_supply/BAT0/power_now)
|
||
|
power_watts=$(${pkgs.bc}/bin/bc <<< "scale=3; $power / 1000000")
|
||
|
|
||
|
echo -e "$bat_name ($bat_status)\nCharge: $bat_pct\nTime: $bat_time\nPower consumption: $power_watts W "
|
||
|
'')
|
||
|
];
|
||
|
}
|