Help us shape the future of Go! Take the 2026 Go Developer Survey

go-rofi-bluetooth-menu

command module
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 5 Imported by: 0

README

go-rofi-bluetooth-menu

A small rofi menu for connecting and disconnecting Bluetooth devices through bluetoothctl. It lists your paired devices, marks the connected ones, and toggles whichever you pick.

Requirements

  • bluetoothctl (BlueZ) on PATH
  • rofi on PATH
  • A Nerd Font for the Bluetooth glyphs (󰂱 / 󰂲)

Install

go install github.com/qikiqi/go-rofi-bluetooth-menu@latest

Or build from a checkout:

go build -o go-rofi-bluetooth-menu .

Usage

This is a rofi script-mode -modi: rofi execs the binary itself, so it's invoked through rofi -modi, not run directly. Bind it to a key in your window manager. For Sway:

bindsym $mod+b exec rofi -show bluetooth -modi "bluetooth:/path/to/go-rofi-bluetooth-menu"

The menu shows one entry per device as <symbol>: <MAC> <name>, connected devices first:

󰂱: AA:BB:CC:DD:EE:FF My Headphones
󰂲: 11:22:33:44:55:66 Living Room Speaker

Picking a connected device (󰂱) disconnects it; picking a disconnected device (󰂲) powers the adapter on and connects it. Dismissing the menu without choosing anything does nothing. Free-typed text that doesn't match a device is rejected by rofi itself — there's no action to take on it.

Manual invocation

Running the binary directly (no ROFI_RETV in the environment, i.e. outside of rofi) prints the same rows rofi would receive, to stdout, for inspection — it does not open a menu:

Flag Default Description
-loglevel info Log verbosity: debug, info, warn, error
-version, -v Print version and build info, then exit

Logs are written to stderr as structured log/slog text.

Exit codes
  • 0 — success, including when a picked line no longer matches a known device.
  • 1 — a fatal error (invalid -loglevel, a bluetoothctl call failing, etc.). The reason is logged before exit.

SIGINT / SIGTERM cancel any in-flight subprocess and exit cleanly.

Development

go build ./...
go vet ./...
go test ./...

The bluetoothctl integration sits behind an interface, so the tests run against a fake and a hermetic stub script — no real hardware required. See ARCHITECTURE.md for the package layout and the script-mode protocol details.

License

MIT — see LICENSE.

Documentation

Overview

Command go-rofi-bluetooth-menu is a rofi script-mode menu for listing and toggling bluetoothctl-managed devices.

Directories

Path Synopsis
internal
program
Package program implements the rofi bluetooth device menu: listing, selecting, and toggling bluetoothctl-managed devices.
Package program implements the rofi bluetooth device menu: listing, selecting, and toggling bluetoothctl-managed devices.
version
Package version prints build/version information derived from the binary's embedded debug.BuildInfo.
Package version prints build/version information derived from the binary's embedded debug.BuildInfo.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL