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

setBrightness action doesn't work #20

Closed
gcordalis opened this issue Nov 29, 2018 · 2 comments
Closed

setBrightness action doesn't work #20

gcordalis opened this issue Nov 29, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@gcordalis
Copy link
Contributor

The setBrightness action doesn't assign the correct value type for shortcuts to handle.

Shortcuts-JS assigns a value type of <integer> where the native Shortcuts App assigns <real>.

Here is an example of the generated shortcut file using Shortcuts-JS:

<array>
  <dict>
    <key>WFWorkflowActionIdentifier</key>
    <string>is.workflow.actions.setbrightness</string>
    <key>WFWorkflowActionParameters</key>
    <dict>
      <key>WFBrightness</key>
      <integer>88</integer>
    </dict>
  </dict>
</array>

And this from the native Shortcuts App:

<array>
  <dict>
    <key>WFWorkflowActionIdentifier</key>
    <string>is.workflow.actions.setbrightness</string>
    <key>WFWorkflowActionParameters</key>
    <dict>
      <key>WFBrightness</key>
      <real>0.8868458271026611</real>
    </dict>
  </dict>
</array>

Building a shortcut using the below code sets the brightness to 100 when loaded into the app.

const fs = require("fs");
const { buildShortcut } = require("@joshfarrant/shortcuts-js");
const { setBrightness } = require("@joshfarrant/shortcuts-js/actions");

const actions = [
  setBrightness({
    brightness: 25
  })
];

const shortcut = buildShortcut(actions);

fs.writeFile("Brightness.shortcut", shortcut, err => {
  if (err) {
    console.error("Something went wrong :(", err);
    return;
  }
  console.log("Shortcut created!");
});
@joshfarrant
Copy link
Owner

Good spot, thanks. Hopefully bplist-creator supports <real>s, if so it should be an easy fix.

I’ll take a look in the morning (if no-one else wants to in the meantime).

@joshfarrant joshfarrant added the bug Something isn't working label Nov 29, 2018
@joshfarrant
Copy link
Owner

Thanks for the fix 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants