Last active
February 6, 2020 09:19
-
-
Save szhu/4c80c9f91d4049d7ae3a6cda55ad3c1d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# Set your desktop background to your screen saver. | |
# Install and activate with: | |
# curl -fsSL https://git.io/vMgM9 | bash | |
# | |
# The screen saver is visible only on desktops created before the screen saver | |
# was started. If you create a desktop and wish to see the screen saver on it | |
# immediately, just do: | |
# open -a ScreenSaverEngine | |
# to bring it in front of the default desktop background. You can also add | |
# /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app | |
# to the Dock and click it to bring it to the front of the desktop. | |
# | |
# ScreenSaverEngine uses minimal CPU when showing screen savers without | |
# animations and 0.0% CPU when the display is asleep. You can test this with: | |
# while true; do sleep 0.5; echo "$(date) $(pgrep ScreenSaverEngine | xargs ps -o '%cpu=' -p)"; done | |
# | |
# ScreenSaverEngine exits with exit code 0 after the screen is unlocked. The | |
# KeepAlive key is set to restart it in this case or if it crashes. | |
# | |
# To disable the screen saver desktop until next login: | |
# launchctl unload ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.plist | |
# To disable the screen saver desktop indefinitely: | |
# launchctl unload -wF ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.plist | |
# To un-disable the screen saver desktop: | |
# launchctl load -wF ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.plist | |
# To uninstall this: | |
# rm ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.plist | |
set -e | |
# Unload any previous versions of this launch agent | |
launchctl stop com.interestinglythere.backgroundsaver || true | |
launchctl unload ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.plist || true | |
# Write launch agent to file | |
cat << EOF > ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.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> | |
<true/> | |
<key>Label</key> | |
<string>com.interestinglythere.backgroundsaver</string> | |
<key>ProcessType</key> | |
<string>Background</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine</string> | |
<string>-background</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
<key>ThrottleInterval</key> | |
<integer>0</integer> | |
</dict> | |
</plist> | |
EOF | |
# Load and start launch agent | |
launchctl load ~/Library/LaunchAgents/com.interestinglythere.backgroundsaver.plist |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment