← back to Desktop Dotbar
preload.js
15 lines
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('dotbar', {
setOpen: (open) => ipcRenderer.send('dotbar:setOpen', !!open),
setBarH: (h) => ipcRenderer.send('dotbar:setBarH', h), // absolute strip height (grip edge-drag, top dock)
setBarW: (w) => ipcRenderer.send('dotbar:setBarW', w), // absolute strip width (grip edge-drag, side dock)
setBarLen: (px) => ipcRenderer.send('dotbar:setBarLen', px), // absolute TOP-strip horizontal length (right-end grip; 0/full = span the screen)
onBarH: (cb) => ipcRenderer.on('dotbar:barH', (_e, h) => cb(h)),
onConfig: (cb) => ipcRenderer.on('dotbar:config', (_e, c) => cb(c)), // { orientation, autohide, barW, barLen }
gripDrag: (on) => ipcRenderer.send('dotbar:gripDrag', !!on), // suppress auto-hide during a grip drag
setOrientation: (o) => ipcRenderer.send('dotbar:setOrientation', o), // 'top' | 'left' | 'right'
cycleOrientation: () => ipcRenderer.send('dotbar:cycleOrientation'),
setAutohide: (on) => ipcRenderer.send('dotbar:setAutohide', !!on),
quit: () => ipcRenderer.send('dotbar:quit'),
});