Skip to content

Instantly share code, notes, and snippets.

@felix021
Created January 25, 2021 03:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save felix021/2454c596a7af46f617b2595c726f2a44 to your computer and use it in GitHub Desktop.
Save felix021/2454c596a7af46f617b2595c726f2a44 to your computer and use it in GitHub Desktop.
Automatically mute your speaker according to specific wifi ssid.
#!/bin/bash
# USAGE: register in crontab with "*/10 0 0 0 0"
YourSSID="YOUR WIFI SSID"
YourDevice="MacBook Pro Speakers"
source /etc/profile
which AdjustVolume &>/dev/null
if [ $? -eq 1 ]; then
echo
echo Please download device-volume-adjuster, unzip AdjustVolume.zip and put the binary to /usr/local/bin/
echo " URL: https://github.com/jonomuller/device-volume-adjuster/releases/tag/v1.0.0"
echo
exit 1
fi
ssid=`/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep ' SSID:' | awk -FSSID:\ '{print $2}'`
if [ "$ssid" == "$YourSSID" ]; then
AdjustVolume -s 0 -n "$YourDevice"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment