diff options
| author | spl3g <spleefer6@yandex.ru> | 2023-12-31 15:08:06 +0300 |
|---|---|---|
| committer | spl3g <spleefer6@yandex.ru> | 2025-05-01 14:56:39 +0300 |
| commit | b8a5c62b112859f463a53ac97b43f7f8cdc544a9 (patch) | |
| tree | 8b320bc9631fbd60ffe4b701e6afee148bb2313a /home-manager/laptop/hyprland/scripts/battery-level.sh | |
| parent | 7db487dba2262af7b7822d110122ff496070ca92 (diff) | |
uhm
Diffstat (limited to 'home-manager/laptop/hyprland/scripts/battery-level.sh')
| -rwxr-xr-x | home-manager/laptop/hyprland/scripts/battery-level.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/home-manager/laptop/hyprland/scripts/battery-level.sh b/home-manager/laptop/hyprland/scripts/battery-level.sh new file mode 100755 index 0000000..cc2d5cd --- /dev/null +++ b/home-manager/laptop/hyprland/scripts/battery-level.sh @@ -0,0 +1,22 @@ +#!/bin/sh +while true; do + # Check the battery level and charging status + battery_info=$(acpi -b) + + # Extract the battery level from the output of `acpi` + battery_level=$(echo $battery_info | grep -o "[0-9]*%" | sed "s/%//") + + # Check if the laptop is charging + if [[ $battery_info == *"Charging"* ]]; then + # If the laptop is charging, do nothing + : + else + # If the battery level is less than 15%, send a notification + if [ "$battery_level" -lt 15 ]; then + notify-send "Battery Low" "Battery level is at $battery_level%. Charge your laptop." + fi + fi + + # Sleep for 5 minutes before checking the battery level again + sleep 300 +done |
