Detect the presence of your Bluetooth device and execute actions on your Mac.

BlueSense analyzes the signal of your Bluetooth device and executes any desired actions when you move or come back at proximity of your Mac.

BlueSense requires OS X 10.10 or later
BlueSense AppleScripts

How to enable the screensaver password on Mac OS X in AppleScript

Launch the screensaver and enable the password to protect your Mac.

script EnableScreenSaverPassword
		-- method 1
		tell application "System Events"
			tell security preferences
				set properties to {require password to wake:true}
			end tell
			tell application id "" to launch
		end tell
		-- method 2 (change user defaults but do not prompt for the password)
		do shell script ("/usr/bin/defaults write askForPassword -int 1")
		do shell script ("/usr/bin/defaults write askForPasswordDelay -int 5")
		-- Launch the  ScreenSaver
		tell application id "" to launch
	on error errString number errorNumber
		log (errString)
	end try
end script