ref(i3status_wrapper)

This commit is contained in:
TheK4n 2023-10-24 23:33:10 +03:00
parent 5f6d518c2c
commit 862ace6718
2 changed files with 28 additions and 27 deletions

View File

@ -8,7 +8,7 @@
general { general {
colors = true colors = true
interval = 2 interval = 5
output_format = i3bar output_format = i3bar
} }
@ -68,7 +68,7 @@ cpu_temperature 0 {
} }
tztime local { tztime local {
format = " %Y-%m-%d  %H:%M:%S" format = "%Y-%m-%d %H:%M"
} }
volume master { volume master {

View File

@ -17,11 +17,6 @@ update_holder() {
echo "$3" | jq --argjson arg_j "$replacement" "(.[] | (select(.instance==\"$instance\"))) |= \$arg_j" echo "$3" | jq --argjson arg_j "$replacement" "(.[] | (select(.instance==\"$instance\"))) |= \$arg_j"
} }
remove_holder() {
local instance="$1"
echo "$2" | jq "del(.[] | (select(.instance==\"$instance\")))"
}
get_device_battery_status() { get_device_battery_status() {
for uuid in $(timeout 1 bluetoothctl devices | cut -f2 -d' ' 2>/dev/null) for uuid in $(timeout 1 bluetoothctl devices | cut -f2 -d' ' 2>/dev/null)
do do
@ -37,14 +32,20 @@ get_device_battery_status() {
update_json_with_text() { update_json_with_text() {
local json="{ \"full_text\": \"$1\", \"color\": \"#FFFFFF\"}" local json="{ \"full_text\": \"$1\", \"color\": \"#FFFFFF\"}"
update_holder holder__headphones "$json" "$2" update_holder "holder__headphones" "$json" "$2"
} }
i3status | (read -r line; echo "$line"; read -r line; echo "$line"; i3status | (
# read first 2 lines without formatting
read -r line
echo "$line"
read -r line
echo "$line"
while true while true
do do
read -r line read -r line
json_array="$(echo "$line" | sed -e 's/^,//')" json_array="$(echo "$line" | sed -e 's/^,//')"
echo ",$(update_json_with_text "$(get_device_battery_status)" "$json_array")" echo "$(update_json_with_text "$(get_device_battery_status)" "$json_array"),"
done done
) )