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 disconnect Mac OS X session in AppleScript

This script qui automatically the current user session on Mac OS X.

Note that if the app loose your device signal, you will be disconnected…

script DisconnectSession
        do shell script ("/System/Library/CoreServices/Menu\\ Extras/ -suspend")
    end try
end script