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
-- Check the battery level | |
set batteryLevel to do shell script "pmset -g batt | grep -Eo \"\\d+%\" | cut -d \"%\" -f 1" | |
set onBattery to do shell script "pmset -g batt | grep -q \"Battery Power\" && echo 1 || echo 0" | |
set onLowPowerMode to do shell script "pmset -g | grep lowpowermode | grep -o \"[0-9]*\" " | |
if onLowPowerMode = "0" and batteryLevel < 20 then | |
do shell script "pmset -a lowpowermode 1" with administrator privileges | |
else if onLowPowerMode = "1" and (batteryLevel > 80 or onBattery = "0") then | |
do shell script "pmset -a lowpowermode 0" with administrator privileges | |
end if |
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
# Tree transformation combinators | |
# portable strategies | |
def seqS(*strategies): | |
def seqaux(tree): | |
tmp = tree | |
for s in strategies: | |
tmp = s(tmp) |