Regenerated
This commit is contained in:
+292
-290
File diff suppressed because it is too large
Load Diff
+12
-10
@@ -2988,23 +2988,25 @@ These are config files for waybar
|
||||
#+BEGIN_SRC sh :tangle generated/.config/waybar/scripts/bluetooth-status.sh :noweb yes :mkdirp yes :eval never
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bt_connected=$(bluetoothctl devices | while read -r line; do
|
||||
mac=$(echo "$line" | awk '{print $2}')
|
||||
bt_connected=""
|
||||
|
||||
while read -r _ mac name_rest; do
|
||||
if [ "$(bluetoothctl info "$mac" | awk '/Connected:/ {print $2}')" = "yes" ]; then
|
||||
echo "$line" | cut -d' ' -f3-
|
||||
bt_connected+="$name_rest\n"
|
||||
fi
|
||||
done)
|
||||
|
||||
icon=""
|
||||
tooltip=null
|
||||
done < <(bluetoothctl devices)
|
||||
|
||||
# icon
|
||||
if [ -n "$bt_connected" ]; then
|
||||
icon=""
|
||||
tooltip=$(echo "$bt_connected" | jq -R -s '.')
|
||||
tooltip=$(printf "%b" "$bt_connected")
|
||||
else
|
||||
icon=""
|
||||
tooltip="No devices connected"
|
||||
fi
|
||||
|
||||
# Output JSON for Waybar
|
||||
jq -n --arg text "$icon" --argjson tooltip "$tooltip" '{text: $text, tooltip: $tooltip}'
|
||||
# ALWAYS produce valid JSON
|
||||
printf '{"text": "%s", "tooltip": "%s"}\n' "$icon" "$tooltip"
|
||||
#+END_SRC
|
||||
|
||||
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bt_connected=$(bluetoothctl devices | while read -r line; do
|
||||
mac=$(echo "$line" | awk '{print $2}')
|
||||
bt_connected=""
|
||||
|
||||
while read -r _ mac name_rest; do
|
||||
if [ "$(bluetoothctl info "$mac" | awk '/Connected:/ {print $2}')" = "yes" ]; then
|
||||
echo "$line" | cut -d' ' -f3-
|
||||
bt_connected+="$name_rest\n"
|
||||
fi
|
||||
done)
|
||||
|
||||
icon=""
|
||||
tooltip=null
|
||||
done < <(bluetoothctl devices)
|
||||
|
||||
# icon
|
||||
if [ -n "$bt_connected" ]; then
|
||||
icon=""
|
||||
tooltip=$(echo "$bt_connected" | jq -R -s '.')
|
||||
tooltip=$(printf "%b" "$bt_connected")
|
||||
else
|
||||
icon=""
|
||||
tooltip="No devices connected"
|
||||
fi
|
||||
|
||||
# Output JSON for Waybar
|
||||
jq -n --arg text "$icon" --argjson tooltip "$tooltip" '{text: $text, tooltip: $tooltip}'
|
||||
# ALWAYS produce valid JSON
|
||||
printf '{"text": "%s", "tooltip": "%s"}\n' "$icon" "$tooltip"
|
||||
|
||||
Reference in New Issue
Block a user