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

Implemented changable icons for AppleScriptTouchBarItem #275

Merged
merged 1 commit into from
Feb 28, 2020

Conversation

FedorZaytsev
Copy link
Collaborator

@FedorZaytsev FedorZaytsev commented Feb 28, 2020

AppleScriptTouchBarItem now allow to specify any number of icons which can be changed from the script.

To do it, you need to return an array of two elements {"TITLE", "ICON_NAME"} from apple script instead of just a string with title. When array is returned, we take second element of the array, pick the corresponding icon from "alternativeIcons" and update it.

Example of usage:

{
    "type": "appleScriptTitledButton",
    "source": {
      "inline": "if (random number from 1 to 2) = 1 then\n\tset val to {\"title\", \"play\"}\nelse\n\tset val to {\"title\", \"pause\"}\nend if\nreturn val"
    },
    "refreshInterval": 1,
    "image": {
      "base64": "iVBORw0KGgoAAAANSUhEUgA..."
    },
    "alternativeImages": {
      "play": {
        "base64": "iVBORw0KGgoAAAANSUhEUgAAAAAA..."
      },
      "pause": {
        "base64": "iVBORw0KGgoAAAANSUhEUgAAAIAA..."
      }
    }
  },

This element would randomly change it icon from alternativeImages["play"] to alternativeImages["pause"] and back.

All old script would still work as before.

AppleScriptTouchBarItem now allow to specify any number of icons which can be changed from the script. You cannot change icon from touch event. To change icon, you need to return array from your script with 2 values - title and icn name. More info in readme
@FedorZaytsev
Copy link
Collaborator Author

Probably a solution for #268 and #216

@Toxblh Toxblh merged commit dbb2f16 into Toxblh:master Feb 28, 2020
@Toxblh
Copy link
Owner

Toxblh commented Feb 28, 2020

tomeresk pushed a commit to tomeresk/MTMR that referenced this pull request Jul 16, 2021
AppleScriptTouchBarItem now allow to specify any number of icons which can be changed from the script. You cannot change icon from touch event. To change icon, you need to return array from your script with 2 values - title and icn name. More info in readme
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

Successfully merging this pull request may close these issues.

2 participants