A little tool that keeps your computer awake when a specified Bluetooth device is nearby. Think of it like a digital leash for your system.
- Detects if a specific personal Bluetooth device (like your phone or watch) is nearby
- Prevents your computer from going to sleep while that device is in range
- Runs quietly in the background as a daemon
You'll need these installed on your system:
- Go 1.21+ - to build it
- bluez-utils - for
hcitoolandl2ping(the Bluetooth magic) - systemd - for
systemd-inhibit(the "don't sleep" magic)
On Arch:
sudo pacman -S bluez-utilsOn Ubuntu/Debian:
sudo apt install bluezOn Fedora:
sudo dnf install bluezgo install github.com/weop/blunt@latest
blunt -i # copy to ~/.local/bin and set up systemd servicego build -o blunt .Or just:
go build .The easiest way:
./blunt -i
# or
./blunt --installThis will:
- Copy
bluntto~/.local/bin/ - If systemd user services are available, ask if you want to install it as a user service
- Enable the service (but not start it automatically)
After installing, make sure ~/.local/bin is in your PATH:
export PATH="$PATH:$HOME/.local/bin"Then configure your device and start the service:
blunt # configure your device
systemctl --user start blunt # start the daemonblunt -u
# or
blunt --uninstallThis will remove the binary, systemd service, and optionally your configuration.
Run it without any flags to pick your "unlock" device:
./bluntIt'll scan for nearby Bluetooth devices, show you a list, and ask you to pick one. This gets saved to ~/.blunt so you don't have to do it again.
If scanning doesn't find your device, you can add it by hand. Edit (or create) ~/.blunt and set the MAC address directly:
{
"device_mac": "AA:BB:CC:DD:EE:FF",
"device_name": "My Phone"
}Replace AA:BB:CC:DD:EE:FF with your phone's Bluetooth MAC address.
- Android: Settings → About Phone → Status → Bluetooth address
- iPhone: Settings → General → About → Bluetooth
./blunt -dThis runs it in the background. If you haven't set up a device yet, it'll complain and tell you to run ./blunt first.
./blunt statusShows your configured device and whether the daemon is running.
./blunt stopKills the background process. Your computer will go back to normal sleep behavior.
- Config lives at
~/.blunt(it's just JSON, you can edit it by hand if you want) - The daemon checks every few seconds (default: 5s) if your device is in range
- Uses
hcitool conto check active connections, orl2pingto ping the device - Uses
systemd-inhibitto prevent system sleep AND idle (screen lock)
Yes, if your screen locker uses systemd/logind for idle detection. blunt takes an idle inhibition lock which tells the system "this session is not idle" - preventing screen lockers from triggering.
If your screen locker doesn't use systemd (pure Wayland idle protocols), you might need to configure it separately to check for the presence of blunt or use a wrapper script.
"hcitool not found" - Install bluez-utils (see Dependencies)
Device not showing up during setup - Make sure your phone/earbuds/whatever are in pairing/discoverable mode. Or just enter the MAC address manually - you can find it in your phone's Bluetooth settings.
Daemon says device is absent but it's right there - Bluetooth can be finicky. Try moving the device closer or increasing the check interval in the config.
"Can't create socket: Operation not permitted" - l2ping needs special permissions. The tool will still work using hcitool con to detect connected devices, but l2ping provides faster detection for devices that aren't actively connected. To enable it:
sudo setcap cap_net_raw+eip /usr/bin/l2pingDevice shows as "not reachable" in status - Make sure Bluetooth is enabled on your phone and it's not in airplane mode. The device doesn't need to be discoverable, just have Bluetooth on.
Do whatever you want with it.