Created
July 19, 2015 16:47
-
-
Save yadomi/b7dfa16f2316a77db72d to your computer and use it in GitHub Desktop.
Run command based on Wifi SSID on OSX
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
SSID=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk '/ SSID/ {print substr($0, index($0, $2))}') | |
WALLPAPERS="/Users/yadomi/Dropbox/Applications/WallCentral" | |
WALLPAPER=$(find $WALLPAPERS -type f -not -path '*/\.*' -not -path '*Icon*' | shuf -n 1) | |
WALLPAPER_FALLBACK="$WALLPAPERS/a495ebd47cd4e0404b272eaea6cedb23.jpg" | |
if [ -z $SSID ]; then | |
exit | |
fi | |
case $SSID in | |
"CakeLabs" | "PlanetExpress" ) | |
echo "Trusted wifi" | |
defaults write com.apple.screensaver askForPassword 0 | |
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'$WALLPAPER'"' | |
;; | |
*) | |
echo "Untrusted, fallback to safety mode" | |
defaults write com.apple.screensaver askForPassword 1 | |
osascript -e 'tell application "Finder" to set desktop picture to POSIX file "'$WALLPAPER_FALLBACK'"' | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When connected to trusted wifi, this script will disable password when waking up from sleep and set a custom wallpaper