cdotfis-mac/dotfiles/.local/bin/sailingMode.sh

11 lines
380 B
Bash
Executable File

#!/bin/bash
BATTERY_PERCENTAGE=$(battery status | awk -F' ' '{print $5}' | tr -d '%')
CHARGING_STATUS=$(battery status | grep -o "smc charging .*" | awk '{print $3}')
if (( BATTERY_PERCENTAGE > 70 )) && [[ $CHARGING_STATUS == "enabled" ]]; then
battery charging off
elif (( BATTERY_PERCENTAGE < 30 )) && [[ $CHARGING_STATUS == "disabled" ]]; then
battery charging on
fi