Files
2026-04-30 00:57:24 +02:00

72 lines
2.6 KiB
TypeScript

import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
export default class BleUnlockPreferences extends ExtensionPreferences {
async fillPreferencesWindow(window: Adw.PreferencesWindow): Promise<void> {
const settings = this.getSettings();
const page = new Adw.PreferencesPage({
title: 'General',
iconName: 'preferences-system-symbolic',
});
window.add(page);
// Device group
const deviceGroup = new Adw.PreferencesGroup({ title: 'Device' });
page.add(deviceGroup);
const deviceRow = new Adw.EntryRow({ title: 'Device MAC Address' });
settings.bind('device-address', deviceRow as any, 'text', Gio.SettingsBindFlags.DEFAULT);
deviceGroup.add(deviceRow);
// Thresholds group
const thresholdGroup = new Adw.PreferencesGroup({ title: 'Thresholds' });
page.add(thresholdGroup);
const lockRow = new Adw.SpinRow({
title: 'Lock Threshold (dBm)',
subtitle: 'Screen locks when RSSI falls below this value',
adjustment: new Gtk.Adjustment({
lower: -100,
upper: 0,
stepIncrement: 1,
pageIncrement: 5,
}),
});
settings.bind('rssi-lock-threshold', lockRow as any, 'value', Gio.SettingsBindFlags.DEFAULT);
thresholdGroup.add(lockRow);
const unlockRow = new Adw.SpinRow({
title: 'Unlock Threshold (dBm)',
subtitle: 'Screen unlocks when RSSI rises above this value',
adjustment: new Gtk.Adjustment({
lower: -100,
upper: 0,
stepIncrement: 1,
pageIncrement: 5,
}),
});
settings.bind('rssi-unlock-threshold', unlockRow as any, 'value', Gio.SettingsBindFlags.DEFAULT);
thresholdGroup.add(unlockRow);
// Polling group
const pollingGroup = new Adw.PreferencesGroup({ title: 'Polling' });
page.add(pollingGroup);
const pollRow = new Adw.SpinRow({
title: 'Poll Interval (seconds)',
subtitle: 'How often to read BLE RSSI',
adjustment: new Gtk.Adjustment({
lower: 1,
upper: 60,
stepIncrement: 1,
pageIncrement: 5,
}),
});
settings.bind('poll-interval', pollRow as any, 'value', Gio.SettingsBindFlags.DEFAULT);
pollingGroup.add(pollRow);
}
}