Skip to content

Instantly share code, notes, and snippets.

@yadomi
Created July 19, 2015 16:47
Show Gist options
  • Save yadomi/b7dfa16f2316a77db72d to your computer and use it in GitHub Desktop.
Save yadomi/b7dfa16f2316a77db72d to your computer and use it in GitHub Desktop.
Run command based on Wifi SSID on OSX
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
@yadomi
Copy link
Author

yadomi commented Jul 20, 2015

When connected to trusted wifi, this script will disable password when waking up from sleep and set a custom wallpaper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment