Created
October 5, 2022 05:23
-
-
Save thejevans/68f0d060414e8fcf0286607b246cc0b6 to your computer and use it in GitHub Desktop.
script to change the framework laptop power led color based on battery/charging status. I use it as a cron job
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# takes desired critical percentage as first argument and | |
# charged percentage as second, both with default values. | |
# example usages: | |
# | |
# framework_powerled_color.sh | |
# framework_powerled_color.sh 10 | |
# framework_powerled_color.sh 10 98 | |
# | |
# requires cat and fw-ectool | |
CAPACITY=$(cat /sys/class/power_supply/BAT1/capacity) | |
PLUGGED=$(cat /sys/class/power_supply/ACAD/online) | |
CRITICAL=${1:-10} | |
CHARGED=${2:-98} | |
if [ "$PLUGGED" -eq "1" ]; then | |
if [ "$CAPACITY" -lt "$CHARGED" ]; then | |
fw-ectool led power amber | |
else | |
fw-ectool led power white | |
fi | |
elif [ "$CAPACITY" -le "$CRITICAL" ]; then | |
fw-ectool led power red | |
else | |
fw-ectool led power white | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment