fix(i3status_wrapper): timeout for bluetoothctl
This commit is contained in:
parent
a200c7d445
commit
5f6d518c2c
@ -3,6 +3,8 @@ exec --no-startup-id ~/.screenlayout/default.sh
|
|||||||
set $SecMon "HDMI-0"
|
set $SecMon "HDMI-0"
|
||||||
|
|
||||||
for_window [tiling] border pixel 3
|
for_window [tiling] border pixel 3
|
||||||
|
smart_borders on
|
||||||
|
|
||||||
set $mod Mod4
|
set $mod Mod4
|
||||||
|
|
||||||
exec --no-startup-id xset s off
|
exec --no-startup-id xset s off
|
||||||
@ -180,7 +182,6 @@ bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcu
|
|||||||
# finds out, if available)
|
# finds out, if available)
|
||||||
bar {
|
bar {
|
||||||
output primary
|
output primary
|
||||||
output nonprimary
|
|
||||||
tray_output primary
|
tray_output primary
|
||||||
status_command exec ~/.local/bin/i3status_wrapper
|
status_command exec ~/.local/bin/i3status_wrapper
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
general {
|
general {
|
||||||
colors = true
|
colors = true
|
||||||
interval = 5
|
interval = 2
|
||||||
output_format = i3bar
|
output_format = i3bar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
# format = "holder__headphones"
|
# format = "holder__headphones"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
# Make sure jq is installed
|
[ -x "/usr/bin/jq" ] || exec i3status
|
||||||
|
|
||||||
update_holder() {
|
update_holder() {
|
||||||
local instance="$1"
|
local instance="$1"
|
||||||
@ -23,11 +23,12 @@ remove_holder() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_device_battery_status() {
|
get_device_battery_status() {
|
||||||
for uuid in $(bluetoothctl devices | cut -f2 -d' ')
|
for uuid in $(timeout 1 bluetoothctl devices | cut -f2 -d' ' 2>/dev/null)
|
||||||
do
|
do
|
||||||
local device_info="$(bluetoothctl info "$uuid")"
|
local device_info
|
||||||
|
device_info="$(timeout 1 bluetoothctl info "$uuid")"
|
||||||
|
|
||||||
if [ -n "$(echo $device_info | grep 'Connected: yes\|Battery Percentage')" ]; then
|
if echo "$device_info" | grep -q 'Connected: yes\|Battery Percentage'; then
|
||||||
echo "$device_info" | grep 'Battery Percentage' | awk -F '[()]' '{ print "🎧🔋"$2"%" }'
|
echo "$device_info" | grep 'Battery Percentage' | awk -F '[()]' '{ print "🎧🔋"$2"%" }'
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -39,9 +40,11 @@ update_json_with_text() {
|
|||||||
update_holder holder__headphones "$json" "$2"
|
update_holder holder__headphones "$json" "$2"
|
||||||
}
|
}
|
||||||
|
|
||||||
i3status | (read line; echo "$line"; read line ; echo "$line" ; read line ; echo "$line" ; while true
|
i3status | (read -r line; echo "$line"; read -r line; echo "$line";
|
||||||
do
|
while true
|
||||||
read line
|
do
|
||||||
json_array="$(echo $line | sed -e 's/^,//')"
|
read -r line
|
||||||
echo ",$(update_json_with_text "$(get_device_battery_status)" "$json_array")"
|
json_array="$(echo "$line" | sed -e 's/^,//')"
|
||||||
done)
|
echo ",$(update_json_with_text "$(get_device_battery_status)" "$json_array")"
|
||||||
|
done
|
||||||
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user