Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh does not reflect config changes #914

Open
halilim opened this issue Feb 19, 2024 · 0 comments
Open

Refresh does not reflect config changes #914

halilim opened this issue Feb 19, 2024 · 0 comments

Comments

@halilim
Copy link

halilim commented Feb 19, 2024

https://github.com/matryer/xbar-plugins/blob/main/CONTRIBUTING.md#plugin-variable-json-files :

You can programmatically modify the JSON files to adjust the values. Use the refresh control API above to refresh plugins after changing variables.

~/Library/Application Support/xbar/plugins/config_refresh_issue.sh:

#!/usr/bin/env bash
set -eo pipefail
IFS=$'\n\t'

# <xbar.var>string(VAR_TEST="initial"): Test</xbar.var>

config_file="$0.vars.json"

if [[ $1 == modify ]]; then
  sed -i '' -E "s/(\"VAR_TEST\": \")[[:alnum:]]*/\1$RANDOM/" "$config_file"
fi

echo '🧪'
echo '---'
echo "Modify config | bash=$0 | param1=modify | refresh=true"
echo "VAR_TEST=\"$VAR_TEST\""

To reproduce: Hit "Modify config" in the plugin menu
Actual: VAR_TEST remains the same in the menu
Expected: VAR_TEST reflects the change

The file itself (~/Library/Application Support/xbar/plugins/config_refresh_issue.sh.vars.json) changes, it's just not reflected in the running plugin.

Hitting the submenu item "xbar > Refresh" doesn't work.

Workaround: submenu "xbar > Refresh all" (or reopen the xbar app). Or get configs manually, e.g.:

config=$(< "$config_file")
function get_config() {
  grep "$1" <<< "$config" | cut -d' ' -f2 | tr -d '",'
}
VAR_TEST=$(get_config 'VAR_TEST')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant