mouse.clicked vs click_script #109
-
Are these two equivalent? sketchybar -m \
--add item tst right \
--set tst \
click_script="echo 'click_script'" \
script="echo 'mouse.clicked'" \
--subscribe tst mouse.clicked would the output when clicked always be the following?
(or the other way around) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
They are not equivalent in the sense that the script is also called by other events and by periodic/forced refreshes with the $SENDER variable available to distinguish these events in the script. The click_script on the other hand is only called on a click and can be seen as the core of the click function in the following more general script when the item is subscribed to mouse.clicked: script.sh #!/usr/bin/env bash
function click() {
source click_script.sh
}
case "$SENDER" in
"mouse.clicked") click
;;
*) #Do something else
;;
esac So, this: sketchybar -m --add item tst right \
--set tst click_script="click_script.sh" does exactly the same as this: sketchybar -m --add item tst right \
--set tst script="script.sh" \
--subscribe tst mouse.clicked
If you are subscribed to the mouse.clicked event AND have set up a click_script, both the click_script and the script are executed, but since the scripts run async, the order of execution can not reliably be assumed to be always: click_script
mouse.clicked it could sometimes also be the other way around. |
Beta Was this translation helpful? Give feedback.
-
Okay, thanks for the clarification! |
Beta Was this translation helpful? Give feedback.
They are not equivalent in the sense that the script is also called by other events and by periodic/forced refreshes with the $SENDER variable available to distinguish these events in the script. The click_script on the other hand is only called on a click and can be seen as the core of the click function in the following more general script when the item is subscribed to mouse.clicked:
script.sh
So, this:
sketchybar -m --add item tst right \ --set tst click_script="click_script.sh"
does exactly the same as this: