Added dwm scripts for battery-status and notification

This commit is contained in:
Sam 2024-07-21 01:03:28 +01:00
parent 46018fb461
commit d5f72ee2fd
3 changed files with 27 additions and 0 deletions

View File

@ -20,6 +20,7 @@
# Notification scripts
./scripts/dunstify-volume-notification.nix
./scripts/dunstify-battery-notification.nix
# Helper scripts
./scripts/emoji-picker.nix
@ -29,6 +30,7 @@
./scripts/git-commit-ai.nix
./scripts/aichat-wrapper.nix
./scripts/dmenu-wifi.nix
./scripts/battery-status.nix
];
home.packages = [

View File

@ -0,0 +1,16 @@
{ 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 "
'')
];
}

View File

@ -0,0 +1,9 @@
{ pkgs, ... }:
{
home.packages = [
(pkgs.writeShellScriptBin "dunstify-battery-notification" ''
msgTag="battery-notify"
${pkgs.dunst}/bin/dunstify -a "batteryNotify" -u critical -i battery-notify -h string:x-dunst-stack-tag:$msgTag "Battery Status" "$(battery-status)" -t 5000
'')
];
}