fix i3blocks bluetooth
This commit is contained in:
parent
fdb8fab853
commit
8e184d2098
@ -26,7 +26,7 @@ cmd_disk_root() {
|
|||||||
|
|
||||||
cmd_disk_home() {
|
cmd_disk_home() {
|
||||||
res="$(df -h /home)"
|
res="$(df -h /home)"
|
||||||
if [ "$(echo "${res}" | awk '/\// {print $6}')" != "/home" ]; then
|
if [ "$(echo "${res}" | awk '/\// {print $6}')" = "/" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
df -h /home | awk '/\// {print " "$3"/"$2}'
|
df -h /home | awk '/\// {print " "$3"/"$2}'
|
||||||
@ -65,7 +65,15 @@ cmd_pomodoro() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd_bluetooth_battery() {
|
cmd_bluetooth_battery() {
|
||||||
return 0
|
for uuid in $(timeout 1 bluetoothctl devices | cut -f2 -d' ' 2>/dev/null)
|
||||||
|
do
|
||||||
|
device_info="$(timeout 1 bluetoothctl info "${uuid}")"
|
||||||
|
|
||||||
|
if echo "${device_info}" | grep -q 'Connected: yes\|Battery Percentage'; then
|
||||||
|
echo "${device_info}" | grep 'Battery Percentage' | awk -F '[()]' '{ print "🎧🔋"$2"%" }'
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
|
|||||||
@ -1,50 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# The idea is to define "holder" modules in i3status config and then replace them
|
|
||||||
|
|
||||||
# In order to make this example work you need to add
|
|
||||||
# order += "tztime holder__headphones"
|
|
||||||
# and
|
|
||||||
# tztime holder__headphones {
|
|
||||||
# format = "holder__headphones"
|
|
||||||
# }
|
|
||||||
|
|
||||||
[ -x "/usr/bin/jq" ] || exec i3status
|
|
||||||
|
|
||||||
update_holder() {
|
|
||||||
instance="${1}"
|
|
||||||
replacement="${2}"
|
|
||||||
echo "${3}" | jq --argjson arg_j "${replacement}" "(.[] | (select(.instance==\"${instance}\"))) |= \$arg_j"
|
|
||||||
}
|
|
||||||
|
|
||||||
get_device_battery_status() {
|
|
||||||
for uuid in $(timeout 1 bluetoothctl devices | cut -f2 -d' ' 2>/dev/null)
|
|
||||||
do
|
|
||||||
device_info="$(timeout 1 bluetoothctl info "${uuid}")"
|
|
||||||
|
|
||||||
if echo "${device_info}" | grep -q 'Connected: yes\|Battery Percentage'; then
|
|
||||||
echo "${device_info}" | grep 'Battery Percentage' | awk -F '[()]' '{ print "🎧🔋"$2"%" }'
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
update_json_with_text() {
|
|
||||||
json="{ \"full_text\": \"${1}\", \"color\": \"#FFFFFF\"}"
|
|
||||||
update_holder "holder__headphones" "${json}" "${2}"
|
|
||||||
}
|
|
||||||
|
|
||||||
i3status | (
|
|
||||||
# read first 2 lines without formatting
|
|
||||||
read -r line
|
|
||||||
echo "${line}"
|
|
||||||
read -r line
|
|
||||||
echo "${line}"
|
|
||||||
|
|
||||||
while true
|
|
||||||
do
|
|
||||||
read -r line
|
|
||||||
json_array="$(echo "${line}" | sed -e 's/^,//')"
|
|
||||||
echo "$(update_json_with_text "$(get_device_battery_status)" "${json_array}"),"
|
|
||||||
done
|
|
||||||
)
|
|
||||||
Loading…
x
Reference in New Issue
Block a user