Comments (8)
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.
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.
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.
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.
I'll make some enquiries with BTT.
from btt.
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.
Thanks. And no worries, you've been more than helpful.
from btt.
cool! closing for now, feel free to reopen / mention me if you find any obstacles
from btt.
Related Issues (20)
- add an abstraction to create a new touchbar widgets in the runtime HOT 1
- Split frontend and backend to classes with different implementation HOT 1
- Create an abstraction to control JSONs better HOT 2
- Allow to use keyboard shortcuts as triggers in BTT HOT 2
- Allow to use regular mouse triggers in BTT HOT 1
- Allow to use siri remote triggers in BTT HOT 1
- Allow to use Magic Mouse triggers in BTT HOT 1
- Allow to use "Other" triggers in BTT HOT 1
- Fix recursive build (webpack, ts) HOT 1
- Allow method chaining HOT 1
- Create vue-press based guide
- fix triggers and widgets handling
- remove event listener does not seem to work in `3.x`
- Create a btt web view boiler plate HOT 1
- Allow the creation of custom events
- Add support for native BTT webview functions HOT 1
- Use new BTT action when operating on triggers
- "Sorry, you have to provide the node/bash binary path manually in the params" when using addEventListener HOT 7
- Support for widgetInstance.addEventListener
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btt.