Skip to content

Instantly share code, notes, and snippets.

@zeha
Created May 2, 2013 10:38
Show Gist options
  • Save zeha/5501415 to your computer and use it in GitHub Desktop.
Save zeha/5501415 to your computer and use it in GitHub Desktop.
bt-proximity: Check if your phone (or any other bluetooth device) is in range.
#!/bin/bash
# sudoers:
# username ALL = NOPASSWD: /usr/bin/hcitool, /bin/mount
# crontab:
# @reboot ~/Source/dotfiles/tools/bt-proximity
# one-time pairing:
# bt-device -c F0:XX:XX:XX:XX:XX
mkdir -p ~/.local/bt-proximity
sudo mount -t tmpfs none ~/.local/bt-proximity
STATEFILE=~/.local/bt-proximity/state
while true; do
sudo hcitool info F0:XX:XX:XX:XX:XX >/dev/null 2>&1 && echo 'present' > $STATEFILE || echo 'absent' > $STATEFILE
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment