dotfiles/pkgs/scripts/bluetoothcharge.sh
delta 27c9f432a5 linux-cachyos 6.9 kernel
unbound dns caching
some hyprland bash scripts
fix graphical glitches on laptop
tailsacle no accept dns
2024-06-18 22:29:17 +03:00

26 lines
613 B
Bash
Executable file

#!/usr/bin/env bash
output=$(bluetoothctl info 2>&1)
if [[ $output == *"Missing device address argument"* ]] || [[ $output == *"DeviceSet (null) not available"* ]]; then
exit 0
fi
charge=$(bluetoothctl info | awk -F ':' '/Battery Percentage: [0-9A-F]+/ {gsub(/.*\(|\).*/, "", $2); print $2}')
tooltip=$(bluetoothctl info | awk -F': ' '/Name/ {print $2}')
#if [[ "$CHARGE" = "0" ]]
#then
# echo ""
#else
#echo "{\"text\":\""$CHARGE"\", \"tooltip\":\""$tooltip"\"}"
#fi
#echo '{"number": "2", "tooltip": "text-text-text"}'
echo -e $charge'%\n'$tooltip
exit 0