Skip to content

Instantly share code, notes, and snippets.

@bradjasper
Created January 9, 2015 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradjasper/1d48239f211c43876114 to your computer and use it in GitHub Desktop.
Save bradjasper/1d48239f211c43876114 to your computer and use it in GitHub Desktop.
Small BASH script to check if Focus is currently activated
ACTIVE_NETWORK=$(echo "open|||get Setup:/Network/Service/$(echo "open|||get State:/Network/Global/IPv4|||d.show" | tr '|||' '\n' | scutil | grep "PrimaryService" | awk '{print $3}') |||d.show" | tr '|||' '\n' | scutil | grep "UserDefinedName" | awk -F': ' '{print $2}')
FOCUS_BLACKHOLE_PID=$(ps aux | grep FocusBlackholeProxy | grep -v grep | awk '{print $2}')
PROXY_URL_OUTPUT=$(networksetup -getautoproxyurl "$ACTIVE_NETWORK")
if [[ $PROXY_URL_OUTPUT == *"focus"* ]]
then
echo "Focus is active!"
else
echo "Focus is not active"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment