From ec84fd7a57e8e32015f6e04f7e42b20996c2e481 Mon Sep 17 00:00:00 2001 From: Jake Ginesin Date: Sat, 11 Jan 2025 21:09:38 -0500 Subject: [PATCH] 231 current 2025-01-11 21:09:28 25.05.20241217.d3c42f1 6.6.66 * --- home/programs/polybar/config.ini | 12 +++++------ home/programs/polybar/default.nix | 20 ++++++++++++++++++- home/programs/polybar/scripts/bluetooth.nix | 22 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 home/programs/polybar/scripts/bluetooth.nix diff --git a/home/programs/polybar/config.ini b/home/programs/polybar/config.ini index ddfcffd..59b0145 100644 --- a/home/programs/polybar/config.ini +++ b/home/programs/polybar/config.ini @@ -274,9 +274,9 @@ exec = "sh /home/synchronous/.config/polybar/pomodoro.sh" label-foreground = ${colors.foreground} format-foreground = ${colors.theme} -[module/bluetooth] -type = custom/script -interval = 10 -exec = /home/synchronous/.config/polybar/scripts/bluetooth.sh -label-foreground = ${colors.foreground} -format-foreground = ${colors.theme} +; [module/bluetooth] +; type = custom/script +; interval = 10 +; exec = /home/synchronous/.config/polybar/scripts/bluetooth.sh +; label-foreground = ${colors.foreground} +; format-foreground = ${colors.theme} diff --git a/home/programs/polybar/default.nix b/home/programs/polybar/default.nix index 621a051..2e6e9a2 100644 --- a/home/programs/polybar/default.nix +++ b/home/programs/polybar/default.nix @@ -10,11 +10,29 @@ mpdSupport = true; pulseSupport = true; }; + + colors = { + background = "#0d0d0d"; + foreground = "#ffffff"; + theme = "#89adfa"; + }; + + bluetoothScript = pkgs.callPackage ./scripts/bluetooth.nix {}; + + bctl = '' + [module/bluetooth] + type = custom/script + interval = 10 + exec = ${bluetoothScript}/bin/bluetooth-ctl + label-foreground = ${colors.foreground} + format-foreground = ${colors.theme} + ''; in { services.polybar = { enable = true; package = mypolybar; - extraConfig = builtins.readFile ./config.ini; + config = ./config.ini; + extraConfig = bctl; # my savior: https://www.reddit.com/r/NixOS/comments/v8ikwq/polybar_doesnt_start_at_launch/ script = '' # echo "none" diff --git a/home/programs/polybar/scripts/bluetooth.nix b/home/programs/polybar/scripts/bluetooth.nix new file mode 100644 index 0000000..28f1c3f --- /dev/null +++ b/home/programs/polybar/scripts/bluetooth.nix @@ -0,0 +1,22 @@ +{pkgs, ...}: let + bctl = "/run/current-system/sw/bin/bluetoothctl"; + sctl = "/run/current-system/sw/bin/systemctl"; +in + pkgs.writeShellScriptBin "bluetooth-ctl" '' + if [ $(${bctl} show | grep "Powered: yes" | wc -c) -eq 0 ] + then + echo "" + else + if [ $(echo info | ${bctl} | grep 'Device' | wc -c) -eq 0 ] + then + echo "" + fi + device=$(${bctl} info | grep "Name" | cut -d ' ' -f 2-) + if [[ "$device" == "" ]] + then + echo "%{F#2193ff}" + else + echo "%{F#2193ff} %{F#ffffff}[$device]" + fi + fi + ''