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 button code #356

Closed
fuyu0425 opened this issue Apr 11, 2023 · 1 comment
Closed

Mouse button code #356

fuyu0425 opened this issue Apr 11, 2023 · 1 comment
Labels

Comments

@fuyu0425
Copy link
Contributor

Idea:
Not just expose "left"/"right"/"other" for a mouse click, but also the button code.
It will be useful for a modern mouse with extra buttons (e.g. mine has forward/back buttons).

Which can be get by

uint32_t mouse_button_code = CGEventGetIntegerValueField(context, kCGMouseEventButtonNumber);

I am not proficient in Objective-C and Apple GUI frameworks.

POC:
fuyu0425@9eac182

My Own Usage for a script to control Music App.

case "$BUTTON" in
 "left")
     PLAYER_STATE=$(osascript -e "tell application \"Music\" to set playerState to (get player state) as text")
     if [[ $PLAYER_STATE == "paused" ]]; then
         osascript -e 'tell application "Music" to play'
     else
         osascript -e 'tell application "Music" to pause'
     fi
     ;;
 "right")
     osascript -e 'tell application "Music" to next track'
     ;;
 "other")
     case "$BUTTON_CODE" in
          "3")
              osascript -e 'tell application "Music" to back track'
              ;;
          "4")
              osascript -e 'tell application "Music" to next track'
              ;;
          *)
              osascript -e 'tell application "Music" to back track'
              ;;
     esac
     ;;
esac
@FelixKratz
Copy link
Owner

Sounds like a good idea, I think I would want the button code in the $INFO variable https://felixkratz.github.io/SketchyBar/config/events

Feel free to send a pull-request for this feature.

@FelixKratz FelixKratz added the enhancement New feature or request label Apr 12, 2023
fuyu0425 added a commit to fuyu0425/SketchyBar that referenced this issue Apr 13, 2023
FelixKratz added a commit that referenced this issue Apr 13, 2023
* mouse button code in INFO environment varaible (#356)

* add JSON $INFO variable to mouse.clicked event

---------

Co-authored-by: Felix Kratz <[email protected]>
mk0417 pushed a commit to mk0417/SketchyBar that referenced this issue Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants