nix-config/modules/hosts/t480/dwm/dwmblocks/battery.nix

23 lines
503 B
Nix

{
flake.modules.homeManager.gui =
{ pkgs, ... }:
{
home.packages = [
(pkgs.writeShellApplication {
name = "status-battery";
runtimeInputs = with pkgs; [ gawk ];
text = ''
percentage=$(battery | grep "percentage:" | awk '{print $2}')
test "$percentage" == "100%" && exit 0
state=$(battery | grep "state:" | awk '{print $2}')
echo "$percentage ($state)";
'';
})
];
};
}