Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Lock/unlock your Mac with your iPhone, Apple Watch, or any other Bluetooth LE devices

NotificationsYou must be signed in to change notification settings

ts1/BLEUnlock

Repository files navigation

Please note that I don't distribute this app on the Mac App Store. You can find it here for free!

CIGithub All ReleasesBuy me a coffee

BLEUnlock is a small menu bar utility that locks and unlocks your Mac by proximity of your iPhone, Apple Watch, or any other Bluetooth Low Energy device.

This document is also available inJapanese (日本語版はこちら).

Features

  • No iPhone app is required
  • Works with any BLE devices that periodically transmits signal fromstatic MAC address
  • Unlocks your Mac for you when the BLE device is near your Mac, without entering password
  • Locks your Mac when the BLE device is away from your Mac
  • Optionally runs your own script upon lock/unlock
  • Optionally wakes from display sleep
  • Optionally pauses and unpauses music/video playback when you're away and back
  • Password is securely stored in Keychain

Requirements

  • A Mac with Bluetooth Low Energy support
  • macOS 10.13 (High Sierra) or later
  • iPhone 5s or newer, Apple Watch (all), or another BLE device that hasstatic MAC address and transmits signal periodically

Installation

Using Homebrew Cask

brew install bleunlock

Manual installation

Download the zip file fromReleases, unzip and move to the Applications folder.

Setting up

On the first launch, it asks for the following permissions, which you must grant:

PermissionDescription
BluetoothObviously, Bluetooth access is required. ChooseOK.
AccessibilityThis is required to unlock the locked screen. ClickOpen System Preferences, click the lock icon on the bottom left to unlock, and turn on BLEUnlock.
Keychain(Not always asked) If asked, you have to chooseAlways Allow because it is required while the screen is locked.
Notification(Optional) BLEUnlock shows a message on the lock screen when it locks the screen. It is helpful to know if it's working properly. Additionally, to see the message on the lock screen, you need to setShow previews toalways in theNotification preference pane.

NOTE: The number of permissions required increases with each version of macOS, so if you are using an older OS, you may not be asked for one or more permissions.

Then it asks your login password to unlock the lock screen.It will be stored safely in Keychain.

Finally, from the menu bar icon, selectDevice.It starts scanning nearby BLE devices.Select your device, and you're done!

Options

OptionDescription
Lock Screen NowIt locks the screen regardless of whether the BLE device is nearby or not; it will unlock once the BLE device moves away and then moves closer again. This is useful to ensure that the screen is locked before you leave your seat.
Unlock RSSIBluetooth signal strength to unlock. Larger value indicates that the BLE device needs to be closer to the Mac to unlock. ChooseDisable to disable unlocking.
Lock RSSIBluetooth signal strength to lock. Smaller value indicates that the BLE device needs to be farther away from the Mac to lock. ChooseDisable to disable locking.
Delay to LockDuration of time before it locks the Mac when it detects that the BLE device is away. If the BLE device comes closer within that time, no lock will occur.
No-Signal TimeoutTime between last signal reception and locking. If you experience frequent "Signal is lost" locking, increase this value.
Wake on ProximityWakes up the display from sleep when the BLE device approaches while locking.
Wake without UnlockingBLEUnlock will not unlock the Mac when the display wakes up from sleep, whether automatically via "Wake on Proximity" or manually. This allows for compatibility with the macOS built-in unlock with Apple Watch feature (which can operate immediately after BLEUnlock wakes the screen), or if you just prefer the lock screen to appear more quickly but don't want it to auto-unlock.
Pause "Now Playing" while LockedOn lock/unlock, BLEUnlock pauses/unpauses playback of music or video (including Apple Music, QuickTime Player and Spotify) that is controlled byNow Playing widget or the ⏯ key on the keyboard.
Use Screensaver to LockIf this option is set, BLEUnlock launches screensaver instead of locking. For this option to work properly, you need to setRequire passwordimmediately after sleep or screen saver begins option inSecurity & Privacy preference pane.
Turn Off Screen on LockTurn off the display immediately when locking.
Set Password...If you changed your login password, use this.
Passive ModeBy default it actively tries to connect to the BLE device and read the RSSI. Most of the time, the default is recommended and works stably. However, if you are using other Bluetooth things like keyboard, mouse, track pad or most notably Bluetooth Personal Hotspot, the default mode may interfere with each other. 2.4GHz WiFi may interfere as well. If you are experiencing instability of Bluetooth, turn on Passive Mode.
Launch at LoginLaunches BLEUnlock when you login.
Set Minimum RSSIDevices with RSSI below this value will not be displayed in the device scan list.

Troubleshooting

Can't find my device in the list

If your BLE device is not from Apple, BLEUnlock may not able to find the device name.If that is the case, your device is displayed as a UUID (long hexadecimal numbers and hyphens).To identify the device, try moving the device closer to or farther away from the Mac and see if the RSSI (dB value) changes accordingly.

If you don't seeany device in the list, try resetting the Bluetooth module as described below.

It fails to unlock

Make sure BLEUnlock is turned on inSystem Preferences >Security & Privacy >Privacy >Accessibility.If it is already on, try turning it off and on again.

If it asks for permission to access its own password in Keychain, you must chooseAlways Allow, because it is needed while the screen is locked.

"Signal is lost" occurs frequently

IncreaseNo-Signal Timeout.Or tryPassive Mode.

My Bluetooth keyboard, mouse, Personal Hotspot, or whatever Bluetooth, went nuts!

Firstly, Shift + Option + Click the Bluetooth icon in the menubar or Control Center, then clickReset the Bluetooth module.

In macOS 12 Monterey, this option is no longer available.Instead, type the command below in Terminal to reset the Bluetooth module:

sudo pkill bluetoothd

This command will ask your login password.

If the problem persists, turn onPassive Mode.

Notes on MAC address

Unlike classic Bluetooth, Bluetooth Low Energy devices can useprivate MAC address.That private address can be random, and can be changed from time to time.

Recent smart devices, both iOS and Android, tend to use private addresses that change every 15 minutes or so. This is probably to prevent tracking.

On the other hand, in order for BLEUnlock to track your device, its MAC address must be static.

Fortunately, on Apple devices, if you are signed in with the same Apple ID as your Mac, the MAC address is resolved to the true (public) address.

For other devices, including Android, the way to resolve the address is unknown.If your non-Apple device changes its MAC address over time, unfortunately BLEUnlock can't support it.

To check if the MAC address is resolved correctly, compare the MAC address displayed in theDevice scan list of BLEUnlock with the one that is displayed on your device.

Run script on lock/unlock

On locking and unlocking, BLEUnlock runs a script located here:

~/Library/Application Scripts/jp.sone.BLEUnlock/event

An argument is passed depending on the type of event:

EventArgument
Locked by BLEUnlock because of low RSSIaway
Locked by BLEUnlock because of no signallost
Unlocked by BLEUnlockunlocked
Unlocked manuallyintruded

NOTE: forintruded event works properly, you have to setRequire passwordimmediately after sleep inSecurity & Privacy preference pane.

Example

Here is an example script which sends a LINE Notify message, with a photo of the person in front of the Mac when it is unlocked manually.

#!/bin/bashset -eo pipefailLINE_TOKEN=xxxxxnotify() {local message=$1local image=$2if ["$image" ];then        img_arg="-F imageFile=@$image"else        img_arg=""fi    curl -X POST -H"Authorization: Bearer$LINE_TOKEN" -F"message=$message" \$img_arg https://notify-api.line.me/api/notify}capture() {    open -Wa SnapshotUnlocker    ls -t /tmp/unlock-*.jpg| head -1}case$1in    away)        notify"$(hostname -s) is locked by BLEUnlock because iPhone is away."        ;;    lost)        notify"$(hostname -s) is locked by BLEUnlock because signal is lost."        ;;    unlocked)#notify "$(hostname -s) is unlocked by BLEUnlock."        ;;    intruded)        notify"$(hostname -s) is manually unlocked."$(capture)        ;;esac

SnapshotUnlocker is an .app created with Script Editor with this script:

do shell script "/usr/local/bin/ffmpeg -f avfoundation -r 30 -i 0 -frames:v 1 -y /tmp/unlock-$(date +%Y%m%d_%H%M%S).jpg"

This app is required because BLEUnlock does not have Camera permission.Giving permission to this app resolves the problem.

Funding

The annual Apple Developer Program fee is funded by donations.

If you like this app, I'd appreciate it if you could make a donation viaBuy Me a Coffee orPayPal Me so I can keep up.

Credits

Icons are based on SVGs downloaded from materialdesignicons.com.They are originally designed by Google LLC and licensed under Apache License version 2.0.

License

MIT

Copyright © 2019-2022 Takeshi Sone.


[8]ページ先頭

©2009-2025 Movatter.jp