add bluetooth_battery.sh script

This commit is contained in:
2024-02-06 20:11:29 +03:00
parent f651c44dfc
commit 690629e3f5

15
bin/bluetooth_battery.sh Executable file
View File

@@ -0,0 +1,15 @@
#! /bin/bash
name="$1"
model_line=$(upower -d | grep -n "$name" | cut -d ':' -f 1)
if [[ "$model_line" == "" ]]; then
exit 1
fi
idx=$(($model_line - 2))
id=$(upower -d | sed "$idx!d" | awk '{print $2}')
percentage=$(upower -i "$id" | grep "percentage: " | awk '{print $2}')
echo "$percentage"