FelixKratz / SketchyBar

A highly customizable macOS status bar replacement
https://felixkratz.github.io/SketchyBar/
GNU General Public License v3.0
5.62k stars 86 forks source link

INFO variable changed permanently after clicking an item to do something #364

Closed emretepedev closed 1 year ago

emretepedev commented 1 year ago

item.sh

#!/bin/bash

bluetooth=(
  icon.font="$SECOND_FONT:Regular:19.0"
  script="$PLUGIN_DIR/bluetooth/run.sh"
  click_script="$PLUGIN_DIR/bluetooth/run_click.sh"
)

sketchybar  -m --add event bluetooth_change "com.apple.bluetooth.status" \
               --add item bluetooth right                                \
               --set bluetooth "${bluetooth[@]}"                         \
               --subscribe bluetooth bluetooth_change

run.sh

#!/bin/bash

source "$CONFIG_DIR/icons.sh"

STATE=$(jq -r '.POWER_STATE' <<<${INFO})

echo $INFO # <<<INFO OUTPUT>>>

case "$STATE" in
"0")
  ICON=
  ;;
"1")
  ICON=
  ;;
*)
  ICON=󰂳
  ;;
esac

sketchybar --set "$NAME" label="" icon="$ICON"

output of $INFO before click the bluetooth item:

{ "ESTIMATED_BANDWIDTH_UTILIZATION" : 3, "DESENSE_DETECTION" : false, "POWER_STATE" : 1, "A2DP_CONNECTION_COUNT" : 0, "SCO_CONNECTION_COUNT" : 0, "CONNECTED_HID_DEVICE_COUNT" : 0 }

output of $INFO after click the bluetooth item:

{ "button": "left", "button_code": 0, "modifier": "none", "modfier_code": 0 }

I downgraded to 2.14.4 for fix it.

FelixKratz commented 1 year ago

Thanks for the report, I have released a hotfix for this in v2.15.1.