diff --git a/home-manager/modules/sway/default.nix b/home-manager/modules/sway/default.nix index 8b51241..fc9ccca 100644 --- a/home-manager/modules/sway/default.nix +++ b/home-manager/modules/sway/default.nix @@ -33,6 +33,7 @@ in ./gammastep.nix ./waybar.nix ./wofi.nix + ./wofi-bluetooth.nix ./yubikey-touch-detector.nix ]; } // (lib.mkIf nixosConfig.jalr.gui.enable { diff --git a/home-manager/modules/sway/wofi-bluetooth.nix b/home-manager/modules/sway/wofi-bluetooth.nix new file mode 100644 index 0000000..76d2d2b --- /dev/null +++ b/home-manager/modules/sway/wofi-bluetooth.nix @@ -0,0 +1,5 @@ +{ nixosConfig, lib, pkgs, ... }: + +lib.mkIf nixosConfig.jalr.bluetooth.enable { + home.packages = [ pkgs.wofi-bluetooth ]; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index 159bea9..08aa561 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -16,4 +16,5 @@ in jalr = prev.recurseIntoAttrs { contact = callPackage ./contact-page { }; }; + wofi-bluetooth = callPackage ./wofi-bluetooth/wofi-bluetooth.nix { }; } diff --git a/pkgs/wofi-bluetooth/wofi-bluetooth.nix b/pkgs/wofi-bluetooth/wofi-bluetooth.nix new file mode 100644 index 0000000..1b1cad6 --- /dev/null +++ b/pkgs/wofi-bluetooth/wofi-bluetooth.nix @@ -0,0 +1,30 @@ +{ lib +, stdenv +, makeWrapper +, bluez +, wofi +, rofi-bluetooth +}: + +stdenv.mkDerivation rec { + pname = "wofi-bluetooth"; + version = rofi-bluetooth.version; + src = rofi-bluetooth.src; + patches = [ + ./wofi-bluetooth.patch + ]; + buildInputs = [ wofi ]; + nativeBuildInputs = [ makeWrapper ]; + installPhase = '' + runHook preInstall + + install -D --target-directory=$out/bin/ ./rofi-bluetooth + + mv $out/bin/rofi-bluetooth $out/bin/wofi-bluetooth + + wrapProgram $out/bin/wofi-bluetooth \ + --prefix PATH ":" ${lib.makeBinPath [ bluez wofi ] } + + runHook postInstall + ''; +} diff --git a/pkgs/wofi-bluetooth/wofi-bluetooth.patch b/pkgs/wofi-bluetooth/wofi-bluetooth.patch new file mode 100644 index 0000000..2b18d7f --- /dev/null +++ b/pkgs/wofi-bluetooth/wofi-bluetooth.patch @@ -0,0 +1,68 @@ +--- a/rofi-bluetooth ++++ b/rofi-bluetooth +@@ -7,14 +7,14 @@ + # + # Author: Nick Clyde (clydedroid) + # +-# A script that generates a rofi menu that uses bluetoothctl to ++# A script that generates a wofi menu that uses bluetoothctl to + # connect to bluetooth devices and display status info. + # + # Inspired by networkmanager-dmenu (https://github.com/firecat53/networkmanager-dmenu) + # Thanks to x70b1 (https://github.com/polybar/polybar-scripts/tree/master/polybar-scripts/system-bluetooth-bluetoothctl) + # + # Depends on: +-# Arch repositories: rofi, bluez-utils (contains bluetoothctl) ++# Arch repositories: wofi, bluez-utils (contains bluetoothctl) + + # Constants + divider="---------" +@@ -231,8 +231,8 @@ + trusted=$(device_trusted "$mac") + options="$connected\n$paired\n$trusted\n$divider\n$goback\nExit" + +- # Open rofi menu, read chosen option +- chosen="$(echo -e "$options" | $rofi_command "$device_name")" ++ # Open wofi menu, read chosen option ++ chosen="$(echo -e "$options" | $wofi_command "$device_name")" + + # Match chosen option to command + case "$chosen" in +@@ -254,7 +254,7 @@ + esac + } + +-# Opens a rofi menu with current bluetooth status and options to connect ++# Opens a wofi menu with current bluetooth status and options to connect + show_menu() { + # Get menu options + if power_on; then +@@ -269,15 +269,16 @@ + pairable=$(pairable_on) + discoverable=$(discoverable_on) + +- # Options passed to rofi ++ # Options passed to wofi + options="$devices\n$divider\n$power\n$scan\n$pairable\n$discoverable\nExit" + else + power="Power: off" + options="$power\nExit" + fi + +- # Open rofi menu, read chosen option +- chosen="$(echo -e "$options" | $rofi_command "Bluetooth")" ++ lines="$(echo -e "$options" | wc -l)" ++ # Open wofi menu, read chosen option ++ chosen="$(echo -e "$options" | $wofi_command "Bluetooth" -L "$lines")" + + # Match chosen option to command + case "$chosen" in +@@ -305,7 +306,7 @@ + } + + # Rofi command to pipe into, can add any options here +-rofi_command="rofi -dmenu $* -p" ++wofi_command="wofi -d -i -p" + + case "$1" in + --status)