add bluetooth_battery.sh script
This commit is contained in:
15
bin/bluetooth_battery.sh
Executable file
15
bin/bluetooth_battery.sh
Executable 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"
|
||||||
Reference in New Issue
Block a user