-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbattery.sh
executable file
·38 lines (36 loc) · 1.18 KB
/
battery.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Dependencies
# battery
# https://github.com/actuallymentor/battery
#
# brightness
# https://github.com/nriley/brightness
if [ "$1" == 'stop' ]; then
battery maintain stop
launchctl stop com.battery.app
elif [ "$1" == 'see' ]; then
ps -ef | grep battery
elif [ "$1" == 'low_power_off' ]; then
[[ $(brightness -l) =~ (0\..*|1.0.*) ]] && last_brightness="${BASH_REMATCH[1]}"
sudo pmset -a lowpowermode 0
sleep 0.3 # takes ~0.3 seconds for low powermode to change brightness on m1pro, may differ for other cpu models
brightness "$last_brightness"
elif [ "$1" == 'low_power_on' ]; then
[[ $(brightness -l) =~ (0\..*|1.0.*) ]] && last_brightness="${BASH_REMATCH[1]}"
sudo pmset -b lowpowermode 1
sleep 0.3 # takes ~0.3 seconds for low powermode to change brightness on m1pro, may differ for other cpu models
brightness "$last_brightness"
elif [ "$1" == 'health' ]; then
ioreg -l -r -n AppleSmartBatteryManager | grep Capacity
elif (($1>20)); then
if (($1<101)); then
battery maintain stop
launchctl stop com.battery.app
battery maintain $1
battery status
else
echo integer cannot be more than 100
fi
else
echo integer cannot be less than 20
fi