mirror of
https://anongit.gentoo.org/git/repo/gentoo.git
synced 2025-06-09 14:44:11 +02:00
Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
51 lines
986 B
Text
51 lines
986 B
Text
#!/sbin/openrc-run
|
|
# Save and restore the SMC's charge end threshold
|
|
|
|
extra_commands="save restore"
|
|
|
|
depend() {
|
|
need udev
|
|
}
|
|
|
|
has_battery() {
|
|
if [ ! -e /sys/class/power_supply/macsmc-battery ]; then
|
|
eerror "macsmc-battery was not found!"
|
|
return 2
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
restore() {
|
|
ebegin "Restoring macsmc-battery saved charge end threshold"
|
|
|
|
has_battery || return $?
|
|
|
|
if [ ! -e /etc/udev/macsmc-battery.conf ]; then
|
|
ewarn "No saved charge end threshold found! Saving current value..."
|
|
save
|
|
return $?
|
|
fi
|
|
|
|
sed -e 's/CHARGE_CONTROL_END_THRESHOLD=//' /etc/udev/macsmc-battery.conf > /sys/class/power_supply/macsmc-battery/charge_control_end_threshold
|
|
return 0
|
|
}
|
|
|
|
save() {
|
|
ebegin "Saving current macsmc-battery charge end threshold"
|
|
|
|
has_battery || return $?
|
|
|
|
sed -e 's/^/CHARGE_CONTROL_END_THRESHOLD=/' /sys/class/power_supply/macsmc-battery/charge_control_end_threshold > /etc/udev/macsmc-battery.conf
|
|
return 0
|
|
}
|
|
|
|
start() {
|
|
restore
|
|
eend $?
|
|
}
|
|
|
|
stop() {
|
|
save
|
|
eend $?
|
|
}
|