Skip to content

Instantly share code, notes, and snippets.

@xurenlu
Created October 14, 2014 09:56
Show Gist options
  • Save xurenlu/3031fc21edfe2c2e6f2c to your computer and use it in GitHub Desktop.
Save xurenlu/3031fc21edfe2c2e6f2c to your computer and use it in GitHub Desktop.
检测蓝牙是否连,如果未连接,则挂起系统;
#!/bin/bash
while true
locked="false"
do
pair=`bluetoothstatus |grep "renlu" |awk -F ":" '{print $1}'`
if [ "${pair}" != "paired" ] ;then
echo "connected:"
else
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
echo "paired:"
fi
sleep 20
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment