Optional VR overlay template

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
bluandClaude Fable 5.1 committed 2026-09-27 12:01:16 +02:00
1 parent 9a3dd06fb5
commit c226195255
2 files changed
+29 -7

No files matched your search

+20 -7
View File
@@ -186,27 +186,40 @@ async function sendNative(ctx: Ctx, wants: { readonly desktop: boolean; readonly
ctx.logger.debug(`Bridge targets not available: ${String(error)}`); ctx.logger.debug(`Bridge targets not available: ${String(error)}`);
return false; return false;
} }
const sinks = pickSinks(targets, wants.desktop, wants.vr); const values = ctx.settings.values;
if (sinks.length === 0) { const desktopSinks = wants.desktop ? pickSinks(targets, true, false) : [];
const vrSinks = wants.vr ? pickSinks(targets, false, true) : [];
if (desktopSinks.length === 0 && vrSinks.length === 0) {
ctx.logger.debug('The bridge has no target for the enabled channels.'); ctx.logger.debug('The bridge has no target for the enabled channels.');
return false; return false;
} }
const values = ctx.settings.values; // VR overlays get their own template when one is set: WayVR draws with a single font and
const lines = reportLines(report, values.template, (e) => { warnTemplate(ctx, e); }); // shows nothing for emoji, so the rich format is often wrong there.
const vrTemplate = values.templateVr.trim() === '' ? values.template : values.templateVr;
const batches: { readonly sinks: readonly string[]; readonly template: string }[] =
vrTemplate === values.template
? [{ sinks: [...desktopSinks, ...vrSinks], template: values.template }]
: [{ sinks: desktopSinks, template: values.template }, { sinks: vrSinks, template: vrTemplate }];
let delivered = false;
for (const batch of batches.filter((b) => b.sinks.length > 0)) {
const lines = reportLines(report, batch.template, (e) => { warnTemplate(ctx, e); });
const result = await ctx.native.notify({ const result = await ctx.native.notify({
title: lines[0] ?? `${report.joiner.name} joined`, title: lines[0] ?? `${report.joiner.name} joined`,
content: lines.slice(1).join('\n'), content: lines.slice(1).join('\n'),
timeoutSecs: values.notifyTimeoutSecs, timeoutSecs: values.notifyTimeoutSecs,
icon: 'security-high', icon: 'security-high',
sinks, sinks: batch.sinks,
// Never critical: KDE ignores the expiry for critical notifications and keeps them on screen. // Never critical: KDE ignores the expiry for critical notifications and keeps them on screen.
urgency: 'normal', urgency: 'normal',
}); });
for (const failure of result.failed) { for (const failure of result.failed) {
if (failure.sink !== 'bridge') ctx.logger.warn(`Bridge target ${failure.sink} failed: ${failure.error}`); if (failure.sink !== 'bridge') ctx.logger.warn(`Bridge target ${failure.sink} failed: ${failure.error}`);
} }
if (!result.ok) ctx.logger.debug('Bridge not reachable or every target refused; falling back.'); delivered ||= result.ok;
return result.ok; }
if (!delivered) ctx.logger.debug('Bridge not reachable or every target refused; falling back.');
return delivered;
} }
async function sendDesktopAndVr(ctx: Ctx, values: SettingsValues<Settings>, report: Report): Promise<void> { async function sendDesktopAndVr(ctx: Ctx, values: SettingsValues<Settings>, report: Report): Promise<void> {
+9
View File
@@ -99,6 +99,15 @@ export const settings = {
'ageVerifiedEmoji pcRankEmoji questRankEmoji platformEmoji inGroupEmoji rejoinEmoji.', 'ageVerifiedEmoji pcRankEmoji questRankEmoji platformEmoji inGroupEmoji rejoinEmoji.',
default: DEFAULT_TEMPLATE, default: DEFAULT_TEMPLATE,
}, },
templateVr: {
kind: 'string',
multiline: true,
label: 'VR overlay template (optional)',
description:
'Used for VR overlay targets instead of the report template. Leave empty to use the same. WayVR draws with one ' +
'font and shows nothing for emoji and most symbols, so keep this to plain text.',
default: '',
},
notifyToast: { notifyToast: {
kind: 'boolean', kind: 'boolean',
label: 'In-app toast', label: 'In-app toast',