Initial commit

This commit is contained in:
2025-10-23 15:56:15 +02:00
commit c07303e8f8
22 changed files with 2774 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#!/bin/bash
# Find all battery devices (BAT0, BAT1, etc.)
BATTERY_DEVICES=$(upower -e | grep 'BAT')
ON_BATTERY=false
# Iterate through all detected batteries
for DEVICE in $BATTERY_DEVICES; do
# Get the state for the current battery device
STATE=$(upower -i $DEVICE | grep "state" | awk '{print $2}')
# Check if the state is 'discharging' for ANY battery
if [ "$STATE" = "discharging" ]; then
ON_BATTERY=true
break # Exit the loop as soon as one is found to be discharging
fi
done
# Check the final condition and suspend if true
if $ON_BATTERY; then
systemctl suspend
fi