mirror of
https://github.com/Ascyii/scripts.git
synced 2026-01-01 04:44:24 -05:00
Init
This commit is contained in:
13
shell/battery_shutdown.sh
Executable file
13
shell/battery_shutdown.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Get battery percentage from /sys/class/power_supply/BAT0/capacity
|
||||
BATTERY=$(cat /sys/class/power_supply/BAT0/capacity)
|
||||
STATUS=$(cat /sys/class/power_supply/BAT0/status)
|
||||
|
||||
echo $BATTERY
|
||||
echo $STATUS
|
||||
|
||||
# Only shutdown if on battery (discharging) and low
|
||||
if [ "$STATUS" = "Discharging" ] && [ "$BATTERY" -lt 15 ]; then
|
||||
systemctl poweroff
|
||||
fi
|
||||
Reference in New Issue
Block a user