polybar: Improve headset battery script
This commit is contained in:
parent
6040e83cd9
commit
9f4a8a7656
1 changed files with 8 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue