From 4a2770c6f54f144df85b5d5919a28686a772e040 Mon Sep 17 00:00:00 2001 From: Alexander Heldt Date: Tue, 19 Sep 2023 22:11:07 +0200 Subject: [PATCH] pinwheel: Add `bluetooth` to `waybar` --- hosts/pinwheel/modules/waybar/default.nix | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/hosts/pinwheel/modules/waybar/default.nix b/hosts/pinwheel/modules/waybar/default.nix index 2d7f1be..c0546aa 100644 --- a/hosts/pinwheel/modules/waybar/default.nix +++ b/hosts/pinwheel/modules/waybar/default.nix @@ -22,6 +22,15 @@ let esac fi ''; + + toggle-bt-power = pkgs.writeShellScript "toggle-bt-power" '' + POWERED_ON=$(bluetoothctl show | grep "Powered: yes") + if [ -z "$POWERED_ON" ]; then + bluetoothctl power on >> /dev/null + else + bluetoothctl power off >> /dev/null + fi + ''; in { home-manager.users.alex = { @@ -40,7 +49,7 @@ in ]; modules-left = [ "hyprland/workspaces" ]; - modules-right = [ "custom/spotify" "wireplumber" "battery" "clock" ]; + modules-right = [ "custom/spotify" "bluetooth" "wireplumber" "battery" "clock" ]; "custom/spotify" = { exec = spotify-status; @@ -48,6 +57,14 @@ in tooltip = false; }; + bluetooth = { + "format-off" = "󰂲"; + "format-on" = ""; + "format-connected" = ""; + "on-click" = "${pkgs.blueman}/bin/blueman-manager"; + "on-click-right" = toggle-bt-power; + }; + wireplumber = { format = "{volume}%"; format-muted = ""; @@ -93,7 +110,7 @@ in background-color: ${background}; } - #custom-spotify, #wireplumber, #battery, #clock { + #custom-spotify, #bluetooth, #wireplumber, #battery, #clock { margin: 0 12px; } '';