Skip to content

mouse.clicked vs click_script #109

Answered by FelixKratz
es183923 asked this question in Q&A
Discussion options

You must be logged in to vote

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 …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by FelixKratz
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #107 on November 12, 2021 11:55.