diff --git a/home-manager/modules/polybar/default.nix b/home-manager/modules/polybar/default.nix index 7659af9..cbd6936 100644 --- a/home-manager/modules/polybar/default.nix +++ b/home-manager/modules/polybar/default.nix @@ -44,16 +44,21 @@ with lib; let }; headset-battery = pkgs.writeShellScript "headset-battery" '' - battery_level=$(${pkgs.headsetcontrol}/bin/headsetcontrol -c -b) + battery_level=$(${pkgs.headsetcontrol}/bin/headsetcontrol -c -b 2> /dev/null) + + if [[ $? -ne 0 ]]; then + printf "󰂑" + exit + fi battery_icons=(󰁺 󰁻 󰁼 󰁽 󰁾 󰁿 󰂀 󰂁 󰂂 󰁹 ) battery_charging="󰂄" - if [ "''${battery_level}" -eq -1 ]; then + if [[ "''${battery_level}" -eq -1 ]]; then printf "%s " "''${battery_charging}" else idx=$(((battery_level / 10))) - if [ "''${idx}" -eq 10 ]; then + if [[ "''${idx}" -eq 10 ]]; then idx=9 fi