diff --git a/daemon.go b/daemon.go index eabf455..248d806 100644 --- a/daemon.go +++ b/daemon.go @@ -114,8 +114,9 @@ func Run(ctx context.Context, cfg *config.Config, opts RunOptions) error { if a.Type == "page" { asm.NotifyManualPage(a.Page) } - for _, pm := range pageMgrs[1:] { - pm.ActivatePage(newPage) + for _, pm := range pageMgrs { + pm.stopPeriodicKeys() + pm.startPeriodicKeys() } web.BroadcastPageChange(newPage) } @@ -195,6 +196,7 @@ func Run(ctx context.Context, cfg *config.Config, opts RunOptions) error { if err := pm.ActivatePage(page); err != nil { slog.Warn("auto-switch: activate page", "error", err) } + pm.stopPeriodicKeys() pm.startPeriodicKeys() } web.BroadcastPageChange(page) diff --git a/static/app.js b/static/app.js index a3c9cb2..18f5451 100644 --- a/static/app.js +++ b/static/app.js @@ -116,7 +116,7 @@ document.addEventListener('alpine:init', () => { syncSettings() { this.settingsForm = { - brightness: this.config.devices?.[0]?.brightness || 75, + brightness: this.getDeviceConfig(this.activeDeckSerial)?.brightness ?? 75, font: this.config.font || 'medium', screensaver_enabled: this.config.screensaver?.enabled || false, screensaver_idle: this.config.screensaver?.idle_seconds || 30, @@ -141,6 +141,10 @@ document.addEventListener('alpine:init', () => { || { keys_x: 5, keys_y: 3, num_keys: 15 } }, + getDeviceConfig(serial) { + return this.config.devices?.find(d => d.serial === serial) + }, + // ── Grid ── get gridKeys() { const page = this.currentPage @@ -183,7 +187,8 @@ document.addEventListener('alpine:init', () => { if (label) url += `&label=${encodeURIComponent(label)}` if (k.icon_scale != null) url += `&icon_scale=${k.icon_scale}` if (k.font_size != null) url += `&font_size=${k.font_size}` - if (k.background) url += `&background=${encodeURIComponent(k.background)}` + const bg = dout?.background || k.background + if (bg) url += `&background=${encodeURIComponent(bg)}` return url }, @@ -584,10 +589,13 @@ document.addEventListener('alpine:init', () => { // ── Settings ── async saveSettings() { - if (!this.config.devices || this.config.devices.length === 0) { - this.config.devices = [{ serial: '', brightness: 75 }] + if (!this.config.devices) this.config.devices = [] + let dev = this.config.devices.find(d => d.serial === this.activeDeckSerial) + if (!dev) { + dev = { serial: this.activeDeckSerial, brightness: 75 } + this.config.devices.push(dev) } - this.config.devices[0].brightness = parseInt(this.settingsForm.brightness) + dev.brightness = parseInt(this.settingsForm.brightness) this.config.font = this.settingsForm.font || 'medium' this.config.screensaver = { enabled: this.settingsForm.screensaver_enabled, diff --git a/static/index.html b/static/index.html index 7f68c6a..1eab822 100644 --- a/static/index.html +++ b/static/index.html @@ -59,15 +59,15 @@ :style="key.displayBg ? { backgroundColor: key.displayBg } : {}" :class="{ empty: !key.configured }" @click="editKey(key.index)"> - - - - + x-text="key.displayText || key.label"> +