Giter VIP home page Giter VIP logo

Comments (8)

Worie avatar Worie commented on May 20, 2024 1

ah yes sorry. I'm not sure about placing them in groups though, I don't think this is the case I've handled. I'll look around and let you know, though don't expect a clean solution for now, more like a hacky-but-maybe-working one :)

from btt.

kimaldis avatar kimaldis commented on May 20, 2024 1

Grabbing the JSON for a group of buttons seems to contain button data. I may have been looking at this from the wrong end. I'll play some more, let you know what I find.

from btt.

Worie avatar Worie commented on May 20, 2024

Do you need to create a button in the runtime by JS? What's the usecase?

Basically this library will do anything that BTT allows. And there's no action for creating widgets/button on the fly afair. Maybe there were some APIs for that but to be honest I'm not But you can create a button within a group and manage it later, yes.

There's add_new_trigger in BTT docs (link), but there's no add_new_button or add_new_widget. You can ask on https://folivora.ai/ directly whether it's possible to cover such case with intergrated webserver - if so, then this library will be able to do it as well, but not until it's enabled on BTT end.

Thanks for your interest in the library!

from btt.

kimaldis avatar kimaldis commented on May 20, 2024

I'm creating groups containing buttons with very similar actions. It would be a lot quicker to do this using a config array or file, creating buttons on the fly when BTT starts.

I came to your library from https://community.folivora.ai/t/dynamically-generated-widgets/2316 which seems to imply dynamically creating widgets is possible, then to the last few lines in clock-widget.js below. How am I misunderstanding this?

// you could also create a new widget on the fly, in the runtime!
const widgetPromise = btt.Widget.create({
...

from btt.

kimaldis avatar kimaldis commented on May 20, 2024

I'll make some enquiries with BTT.

from btt.

Worie avatar Worie commented on May 20, 2024

You'd have to create a new group on the fly or update existing one. You can use btt.do method to do direct calls to BTT built in webserver.

For example:

btt.do('add_new_trigger',  `
  {
    "BTTTriggerType" : 630,
    "BTTTriggerTypeDescription" : "Group",
    "BTTTriggerClass" : "BTTTriggerTypeTouchBar",
    "BTTPredefinedActionType" : -1,
    "BTTPredefinedActionName" : "No Action",
    "BTTEnabled2" : 1,
    "BTTUUID" : "3B4E8CE2-56CD-40CB-84F8-D552EAF716EF",
    "BTTNotesInsteadOfDescription" : 0,
    "BTTEnabled" : 1,
    "BTTModifierMode" : 0,
    "BTTOrder" : 33,
    "BTTDisplayOrder" : 0,
    "BTTMergeIntoTouchBarGroups" : 0,
    "BTTAdditionalActions" : [
      {
        "BTTTriggerType" : 639,
        "BTTTriggerTypeDescription" : "Apple Script Widget",
        "BTTTriggerClass" : "BTTTriggerTypeTouchBar",
        "BTTPredefinedActionType" : -1,
        "BTTPredefinedActionName" : "No Action",
        "BTTEnabled2" : 1,
        "BTTUUID" : "14260C6B-E5FC-4EE4-BAC8-7D920819E333",
        "BTTNotesInsteadOfDescription" : 0,
        "BTTEnabled" : 1,
        "BTTModifierMode" : 0,
        "BTTOrder" : 0,
        "BTTDisplayOrder" : 0,
        "BTTMergeIntoTouchBarGroups" : 0,
        "BTTTriggerConfig" : {
          "BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
          "BTTTouchBarItemIconWidth" : 22,
          "BTTTouchBarButtonTextAlignment" : 0,
          "BTTTouchBarItemPlacement" : 0,
          "BTTTouchBarButtonFontSize" : 15,
          "BTTTouchBarScriptUpdateInterval" : 5,
          "BTTTouchBarAlwaysShowButton" : false,
          "BTTTBWidgetWidth" : 400,
          "BTTTouchBarAppleScriptStringRunOnInit" : false,
          "BTTTouchBarAppleScriptString" : "return do shell script \"date\" #example: execute a shell script and use the result",
          "BTTTouchBarButtonWidth" : 100,
          "BTTTouchBarOnlyShowIcon" : false,
          "BTTTouchBarFreeSpaceAfterButton" : 5,
          "BTTTouchBarAppleScriptUsePath" : 0,
          "BTTTouchBarItemIconHeight" : 22,
          "BTTTouchBarItemPadding" : 0
        }
      },
      {
        "BTTWidgetName" : "No Name",
        "BTTTriggerType" : 642,
        "BTTTriggerTypeDescription" : "Shell Script \/ Task Widget",
        "BTTTriggerClass" : "BTTTriggerTypeTouchBar",
        "BTTPredefinedActionType" : -1,
        "BTTPredefinedActionName" : "No Action",
        "BTTShellScriptWidgetGestureConfig" : "\/bin\/bash:::-c",
        "BTTEnabled2" : 1,
        "BTTUUID" : "F1E7B9E8-D32D-478B-8AA5-3CC24CA708B2",
        "BTTNotesInsteadOfDescription" : 0,
        "BTTEnabled" : 1,
        "BTTModifierMode" : 0,
        "BTTOrder" : 1,
        "BTTDisplayOrder" : 0,
        "BTTMergeIntoTouchBarGroups" : 0,
        "BTTTriggerConfig" : {
          "BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
          "BTTTouchBarItemIconWidth" : 22,
          "BTTTouchBarButtonTextAlignment" : 0,
          "BTTTouchBarItemPlacement" : 0,
          "BTTTouchBarButtonFontSize" : 15,
          "BTTTouchBarShellScriptString" : "#example:\n{ echo \"Current Time: \" & date; }  | tr -d '\\n'",
          "BTTTouchBarScriptUpdateInterval" : 5,
          "BTTTouchBarAlwaysShowButton" : false,
          "BTTTBWidgetWidth" : 400,
          "BTTTouchBarAppleScriptStringRunOnInit" : false,
          "BTTTouchBarButtonWidth" : 100,
          "BTTTouchBarOnlyShowIcon" : false,
          "BTTTouchBarButtonName" : "No Name",
          "BTTTouchBarFreeSpaceAfterButton" : 5,
          "BTTTouchBarItemIconHeight" : 22,
          "BTTTouchBarItemPadding" : 0
        }
      },
      {
        "BTTWidgetName" : "No Name",
        "BTTTriggerType" : 642,
        "BTTTriggerTypeDescription" : "Shell Script \/ Task Widget",
        "BTTTriggerClass" : "BTTTriggerTypeTouchBar",
        "BTTPredefinedActionType" : -1,
        "BTTPredefinedActionName" : "No Action",
        "BTTShellScriptWidgetGestureConfig" : "\/bin\/bash:::-c",
        "BTTEnabled2" : 1,
        "BTTAlternateModifierKeys" : 0,
        "BTTUUID" : "D62C7B04-8413-4BF9-BA2B-97E5D2255082",
        "BTTNotesInsteadOfDescription" : 0,
        "BTTEnabled" : 1,
        "BTTModifierMode" : 0,
        "BTTOrder" : 2,
        "BTTDisplayOrder" : 0,
        "BTTMergeIntoTouchBarGroups" : 0,
        "BTTTriggerConfig" : {
          "BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
          "BTTTouchBarItemIconWidth" : 22,
          "BTTTouchBarButtonTextAlignment" : 0,
          "BTTTouchBarItemPlacement" : 0,
          "BTTTouchBarButtonFontSize" : 15,
          "BTTTouchBarShellScriptString" : "#example:\n{ echo \"Current Time: \" & date; }  | tr -d '\\n'",
          "BTTTouchBarScriptUpdateInterval" : 5,
          "BTTTouchBarAlwaysShowButton" : false,
          "BTTTBWidgetWidth" : 400,
          "BTTTouchBarAppleScriptStringRunOnInit" : false,
          "BTTTouchBarButtonWidth" : 100,
          "BTTTouchBarOnlyShowIcon" : false,
          "BTTTouchBarFreeSpaceAfterButton" : 5,
          "BTTTouchBarItemIconHeight" : 22,
          "BTTTouchBarItemPadding" : 0
        }
      }
    ],
    "BTTTriggerConfig" : {
      "BTTTouchBarButtonColor" : "75.323769, 75.323769, 75.323769, 255.000000",
      "BTTTouchBarItemIconWidth" : 22,
      "BTTTouchBarButtonTextAlignment" : 0,
      "BTTTouchBarItemPlacement" : 0,
      "BTTTouchBarButtonFontSize" : 15,
      "BTTTouchBarAlwaysShowButton" : false,
      "BTTTBWidgetWidth" : 400,
      "BTTTouchBarButtonWidth" : 100,
      "BTTTouchBarOnlyShowIcon" : false,
      "BTTTouchBarFreeSpaceAfterButton" : 5,
      "BTTTouchBarItemIconHeight" : 22,
      "BTTTouchBarItemPadding" : 0,
      "BTTKeepGroupOpenWhileSwitchingApps" : false
    }
  }
`);

Should theoretically create a new group with 3 buttons. Buttons are the array under BTTAdditionalActions key. So if you modify those, and rerun, you should get different results. Additionaly, there's also a native update_trigger action that allows you to modify existing triggers (in this case - a group).

It should work, may require a little bit of playing around with it but makes sense. I cannot test it though and won't be able to anytime soon :(

from btt.

kimaldis avatar kimaldis commented on May 20, 2024

Thanks. And no worries, you've been more than helpful.

from btt.

Worie avatar Worie commented on May 20, 2024

cool! closing for now, feel free to reopen / mention me if you find any obstacles

from btt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.