- Enable invert colors shortcut:
System Preferences... -> Keyboard -> Accessibility -> Invert colors [x] - Allow macscript to modify Accessibility
System Preferences... -> Security & Privacy -> Accessibility -> Privacy -> + -> osascript - Test that it's working from your shell:
osascript -e "tell application \"System Events\"" -e "key code 28 using {command down, option down, control down}" -e "end tell" - Create the script
sudo vim /etc/batteryScript.applescript
set Cap to (do shell script "ioreg -w0 -l | grep ExternalChargeCapable")
tell Cap to set {wallPower} to {last word of paragraph 1}
if wallPower = "Yes" then
return 0
else
set Cap to (do shell script "ioreg -wO -l | grep AppleRaw")
tell Cap to set {Max, Available} to {last word of paragraph 2, last word of paragraph 1}
set Pct to round (100 * Available / Max)
if Pct <= 5 then
tell application "System Events" key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
if Pct <= 3 then
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
delay 1
tell application "System Events"
key code 28 using {command down, option down, control down}
end tell
if Pct <= 1 then
display notification "Computer is about to shutdown!" with title "---=== WARNING ===---"
beep 5
do shell script "say -v \"Alex\" \"PLUG ME IN NOW\""
end if
end if
end if
end if - Configure script access:
sudo chmod +rx /etc/batteryScript.applescript - Invoking script
vim ~/Library/LaunchAgents/batteryAlert.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key>Label</key>
<string>batteryAlert</string>
<key>LowPriorityIO</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/osascript</string>
<string>/etc/batteryScript.applescript</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Battery Alert</string>
<key>StartInterval</key>
<integer>30</integer>
</dict>
</plist>
- Reboot the OS or manually load the launchd module.
launchctl load ~/Library/LaunchAgents/batteryAlert.plist
Showing posts with label macos. Show all posts
Showing posts with label macos. Show all posts
Thursday, October 10, 2019
Blink the screen when your Mac needs to charge
Saturday, March 14, 2015
macOS config for Finder
Open the terminal
Full path in Finder title bar$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Show all files
$ defaults write com.apple.finder AppleShowAllFiles YES
Hold 'alt' on your keyboard, then right click on the Finder icon in the dock and click Relaunch.
OR
$ killall Finder
To unable the F* keys on the keyboard:
Choose Apple Menu > System Preferences.
Click Keyboard.
Click the Keyboard tab.
Select the option Use All F1, F2, etc. keys as standard function keys.
Quit System Preferences.
IMPORTANT: When this option is selected, press the Fn key to use the special features printed on each key.
Full path in Finder title bar$ defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
Show all files
$ defaults write com.apple.finder AppleShowAllFiles YES
Hold 'alt' on your keyboard, then right click on the Finder icon in the dock and click Relaunch.
OR
$ killall Finder
To unable the F* keys on the keyboard:
Choose Apple Menu > System Preferences.
Click Keyboard.
Click the Keyboard tab.
Select the option Use All F1, F2, etc. keys as standard function keys.
Quit System Preferences.
IMPORTANT: When this option is selected, press the Fn key to use the special features printed on each key.
Subscribe to:
Posts (Atom)