A good shortcut to check and toggle your Macbook's Low Power Mode. Check out https://github.com/andersonaddo/xbar-low-power-mode-tool for important installation instructions!
#!/usr/bin/env bash
# <xbar.title>Mac Low Power Mode Manager</xbar.title>
# <xbar.version>v1.0</xbar.version>
# <xbar.author>Anderson</xbar.author>
# <xbar.author.github>andersonaddo</xbar.author.github>
# <xbar.desc>A good shortcut to check and toggle your Macbook's Low Power Mode. Check out https://github.com/andersonaddo/xbar-low-power-mode-tool for important installation instructions!</xbar.desc>
# <xbar.image>https://raw.githubusercontent.com/andersonaddo/xbar-low-power-mode-tool/main/icon.png</xbar.image>
# <xbar.abouturl>https://github.com/andersonaddo/xbar-low-power-mode-tool</xbar.abouturl>
#icons (144dpi, each about 34 x 34ppx)
ac_leaf_image="iVBORw0KGgoAAAANSUhEUgAAACQAAAAmCAYAAACsyDmTAAAAAXNSR0IArs4c6QAAAOZlWElmTU0AKgAAAAgABgESAAMAAAABAAEAAAEaAAUAAAABAAAAVgEbAAUAAAABAAAAXgExAAIAAAAhAAAAZgEyAAIAAAAUAAAAiIdpAAQAAAABAAAAnAAAAAAAAACQAAAAAQAAAJAAAAABQWRvYmUgUGhvdG9zaG9wIDIxLjIgKE1hY2ludG9zaCkAADIwMjM6MDE6MDYgMTc6Mzg6MzMAAASQBAACAAAAFAAAANKgAQADAAAAAQABAACgAgAEAAAAAQAAACSgAwAEAAAAAQAAACYAAAAAMjAyMzowMTowNiAxNzozNzo0MgCNXXmpAAAACXBIWXMAABYlAAAWJQFJUiTwAAAHvmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNi4wLjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgIC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v7duzOzQ0N/cUHiRZERPBF/iL/ETuBPyc/FSyIYFUcSkQE6bKIfMrGISWxALrNa4DEsOpAXZyUcHMP9tP7YxoURHf62LcUiRwQ1DFOMsSDhnnhdnBKnxd8ib0BAgyQ4fxa3xDHReuLtirfFG2JXxNZ6idUaMd+LH8Vv4ob4UqyxLAmnSILFeZSb3tx2TTYlHTVUaOlJkD2Rb8zYVIwTYoNtiaWE9vNofzoKWW+JVduZENjG/R5J3lSkc2/xzTk1l1MxcU9pqS+gEE4h4EVLObzeQelulAwJ8i9wMV8U5Io4ITp5Hrdeb2qliz3N6H34SZn5AvOpGGIdm5NWljqDA0eeoCVaJ3UR+LMvwLbIpfhOpFMAHTZHwH2QgzfwzZvr8jlBvT+s85pv8mtJwSe7mmTuLmDbw5meeUE22JHukfg12VCkQUfp2pJ4J8lcfoB15DfiU5FPxQUKuADvivhT5Ip4U3ROiYeI+8PH74WVDeMD6fD1HRJldBF5F9GRI/pUdVAtgoHMGknWRTrFDze3obMtMX9Dvy1++GP3QVwTOWEPReLxW1kU/dshZw2SRRI0zpvkkm2+9jZlulWIm9se5HsIX3eNk9QE9krpU+BPIn5D46JP1vckTyYd3enpjOZHNjVrAENae1pQKBsazInz4oxIMXTcJ1BiL9yN3tX+zUied6G0VmccdEEk8h5EJl9eIOs1/kdBdbKTCKVNeRK/gdmcy4K47s8LunSonao5y8Kcu01Bm6kgfhcofCrimEyKA3YRce4Y1nseR3KSG1S1cOO+EqPRWcivVcMoxZD8mcgVwP+GnyBXP5UPmnSmLa6K98XuH9WpkfgE1LmdAAAAAElFTkSuQmCC"
#Power modes
NOT_SUPPORTED=0
LOW_POWER_MODE=2
NORMAL_MODE=3
is_in_low_power_mode=0
is_charging=0
get_power_info() {
local mode_info_raw=$(pmset -g | grep lowpowermode)
local charging_status_raw=$(pmset -g batt | grep "Now drawing")
if [[ $mode_info_raw == *"0"* ]]; then
is_in_low_power_mode=$NORMAL_MODE
elif [[ $mode_info_raw == *"1"* ]]; then
is_in_low_power_mode=$LOW_POWER_MODE
else
is_in_low_power_mode=$NOT_SUPPORTED
fi
if [[ $charging_status_raw == *"AC Power"* ]]; then
is_charging=1
fi
}
toggle_low_power_mode() {
get_power_info
local new_mode=0
if [[ $is_in_low_power_mode == $NORMAL_MODE ]]; then
new_mode=1
elif [[ $is_in_low_power_mode == $LOW_POWER_MODE ]]; then
new_mode=0
fi
if [[ $is_charging == 1 ]]; then
sudo pmset -c lowpowermode $new_mode #changing only the ac power settings
else
sudo pmset -b lowpowermode $new_mode #changing only the battery power settings
fi
}
main() {
get_power_info
if [[ $is_in_low_power_mode == $NOT_SUPPORTED ]]; then
echo "-"
exit 0
fi
if [[ $is_in_low_power_mode == $NORMAL_MODE ]]; then
local image=$([[ $is_charging == 1 ]] && echo "$ac_no_leaf_image" || echo "$battery_no_leaf_image")
echo "| templateImage=$image"
echo "---"
echo "Low Power Mode is off (for AC power)"
elif [[ $is_in_low_power_mode == $LOW_POWER_MODE ]]; then
local image=$([[ $is_charging == 1 ]] && echo "$ac_leaf_image" || echo "$battery_leaf_image")
echo "LPM | templateImage=$image color=lightgreen"
echo "---"
echo "Low Power Mode is on $is_charging_text"
fi
if [[ $is_in_low_power_mode == $LOW_POWER_MODE ]] || [[ $is_in_low_power_mode == $NORMAL_MODE ]]; then
if [[ $is_charging == 1 ]]; then
echo "Toggle Low Power Mode (for AC power) | bash='$0' param1=toggle_mode terminal=false refresh=true"
else
echo "Toggle Low Power Mode (for battery) | bash='$0' param1=toggle_mode terminal=false refresh=true"
fi
fi
echo "Refresh | refresh=true"
}
if [ "$1" == "toggle_mode" ]; then
toggle_low_power_mode
else
main
fi