feat(touch_bar): basic integration

This commit is contained in:
Elian Doran
2025-03-08 11:39:04 +02:00
parent 4cffc50218
commit a170bec3db
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import utils from "../services/utils.js";
import Component from "../components/component.js";
export default class TouchBarWidget extends Component {
remote: typeof import("@electron/remote");
constructor() {
super();
this.remote = utils.dynamicRequire("@electron/remote") as typeof import("@electron/remote");
this.#setTouchBar();
}
#setTouchBar() {
const touchBarData = this.#buildTouchBar();
this.remote.getCurrentWindow().setTouchBar(touchBarData);
console.log("Setting touch bar", touchBarData);
}
#buildTouchBar() {
const { TouchBarButton } = this.remote.TouchBar;
const items = [
new TouchBarButton({
label: "New note",
click: () => {
console.log("New note pressed.");
}
})
];
return new this.remote.TouchBar({
items
});
}
}