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

Using update_freq + drawing=off prevents script from running again #318

Closed vfosterm closed 1 year ago

vfosterm commented 1 year ago

As soon as sketchybar -m --set <module> drawing=off is executed within a script that script will never run again despite the set update_freq.

Example items/vpn.sh

sketchybar -m --add item vpn right \
              --set vpn script="~/.config/sketchybar/plugins/vpn.sh"\
                        update_freq=15

example plugins/vpn.sh

#!/usr/bin/env sh
# VPN=$(scutil --nc list | grep Connected | sed -E 's/.*"(.*)".*/\1/')
VPN="$(ifconfig | grep "utun3")"
if [[ "$VPN" != "" ]]; then
  sketchybar -m --set vpn icon= drawing=on  
  echo "drawing enabled"
else
  sketchybar -m --set vpn drawing=off
  echo "drawing disabled"
fi

Script executes fine and works as expected when rerun from CLI.

Workaround in this case is to use icon.drawing instead of drawing. Not sure if this behaviour is as expected

FelixKratz commented 1 year ago

Check out the updates property in the docs: https://felixkratz.github.io/SketchyBar/config/items#scripting-properties

Most configs default to updates=when_shown, this disables scripts from running for items that are not shown.

Simply set it to updates=on:

sketchybar --set <name> updates=on