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

mouse.exited and mouse.exited.global not properly triggered? #564

Open
aspauldingcode opened this issue Jun 12, 2024 · 2 comments
Open

mouse.exited and mouse.exited.global not properly triggered? #564

aspauldingcode opened this issue Jun 12, 2024 · 2 comments

Comments

@aspauldingcode
Copy link

Having issues keeping my popup drawing set as off when mouse has exited the apple item.
in my apple.sh:

# Handle mouse events
case "$SENDER" in
  "mouse.entered")
    sleep 2  # Wait for 2 seconds before showing the popup
      sketchybar --set $NAME popup.drawing=on
    ;;
  "mouse.exited" | "mouse.exited.global")
    sketchybar --set $NAME popup.drawing=off
    ;;
  "mouse.clicked")
    sketchybar --set $NAME popup.drawing=toggle
    ;;
  "routine")
    ;;
esac

I wanted to add a nested if statement which double checks after 2 seconds if I am still hovered on the item, before setting the popup drawing=on.

However, the code above doesn't do this, because if I add the nested for loop it seems to still think it's hovered. I'm not exactly sure how to approach this.

@aspauldingcode
Copy link
Author

it might be more of: how do I do this?
before triggering the popup, I want it to check for 2 seconds (in case I move the mouse away, it should instead not popup). If I hold on the item for 2 seconds, and after 2 seconds I am still hovering, then it would know I'm expecting a popup and it will set popup drawing on.

@cagdassalur
Copy link

these are events that trigger the instant they happen, so it you won't get if the mouse is on the item afterwards.
You can consider doing something like this:

# on the entered event
rm /tmp/sk_exited_"$NAME"
(
  sleep 2
  [[ -f /tmp/sk_exited_"$NAME" ]] || sketchybar --set $NAME popup.drawing=on
) &

# on the exited event
touch /tmp/sk_exited_"$NAME"

With this, exit events set a flag, so you can read that 2 seconds after the enter event to know if your cursor is still didn't exit.

Maybe there's a more straightforward way of doing it, but idk

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

2 participants