Skip to content

Instantly share code, notes, and snippets.

@lachiefish
lachiefish / charge-threshold.sh
Last active October 16, 2024 19:48
Read and set battery charge thresholds on Linux (BAT0) - Run as root or with sudo - NOTE: Your battery may not be BAT0, run 'ls /sys/class/power_supply/' before this script to make sure.
#!/bin/bash
# Get current charge start threshold (in percent)
charge_start=$(cat /sys/class/power_supply/BAT0/charge_start_threshold)
echo "Current charge start threshold: $charge_start%"
# Get current charge end threshold (in percent)
charge_end=$(cat /sys/class/power_supply/BAT0/charge_end_threshold)
echo "Current charge end threshold: $charge_end%"