diff options
| author | Alexander Kassouni <alex@kassouni.net> | 2026-09-26 11:41:51 -0700 |
|---|---|---|
| committer | Alexander Kassouni <alex@kassouni.net> | 2026-09-26 11:41:51 -0700 |
| commit | ce3ce1cc3f3bce57a3961a37942bc509dfb5e455 (patch) | |
| tree | 6ebb8d3e3d402697b69bc9dbcba39ce908ca696c /users/kassouni/palette/bluetooth.nix | |
| parent | 47dde98fd2cf11ea544bb1c8d8d548ee0bda0f54 (diff) | |
reorganize firefox, laptop stuff
Diffstat (limited to 'users/kassouni/palette/bluetooth.nix')
| -rw-r--r-- | users/kassouni/palette/bluetooth.nix | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/users/kassouni/palette/bluetooth.nix b/users/kassouni/palette/bluetooth.nix index 71e1aaf..4d2a594 100644 --- a/users/kassouni/palette/bluetooth.nix +++ b/users/kassouni/palette/bluetooth.nix @@ -13,14 +13,13 @@ # The interpolated store paths below are longer than 79 columns. flakeIgnore = [ "E501" ]; } '' - import html import json import subprocess import sys BT = "${pkgs.bluez}/bin/bluetoothctl" JC = "${pkgs.jc}/bin/jc" - ROFI = "${pkgs.rofi}/bin/rofi" + FUZZEL = "${pkgs.fuzzel}/bin/fuzzel" def devices(*args): @@ -38,10 +37,9 @@ def label(device, connected): - """Pango markup row. Names are escaped, they are not our text.""" - name = html.escape(device["name"]) + name = device["name"] if device["address"] in connected: - name += ' <span alpha="45%">connected</span>' + name += " (connected)" return name @@ -56,8 +54,7 @@ rows = [label(d, connected) for d in known] choice = subprocess.run( - [ROFI, "-dmenu", "-i", "-markup-rows", "-format", "i", - "-p", "bluetooth"], + [FUZZEL, "--dmenu", "--index", "--prompt", "bluetooth "], input="\n".join(rows), capture_output=True, text=True, @@ -65,7 +62,11 @@ if choice.returncode != 0: return 1 - device = known[int(choice.stdout.strip())] + index = int(choice.stdout.strip() or -1) + if not 0 <= index < len(known): + return 1 + + device = known[index] action = ( "disconnect" if device["address"] in connected else "connect" ) |
