lockeys-service: added a component registration system to avoid polling when not necessary

This commit is contained in:
Lemmy
2026-02-13 13:31:42 -05:00
parent aa10b9791d
commit 8c776b5504
3 changed files with 45 additions and 3 deletions
+15
View File
@@ -298,6 +298,20 @@ Variants {
}
}
// Register/unregister LockKeysService polling based on whether LockKey OSD is enabled
onLockKeyOSDEnabledChanged: {
if (lockKeyOSDEnabled) {
LockKeysService.registerComponent("osd:" + (modelData?.name || "unknown"));
} else {
LockKeysService.unregisterComponent("osd:" + (modelData?.name || "unknown"));
}
}
Component.onCompleted: {
if (lockKeyOSDEnabled) {
LockKeysService.registerComponent("osd:" + (modelData?.name || "unknown"));
}
}
// LockKeys monitoring with a cleaner approach
// Only connect when LockKey OSD is enabled to avoid starting the service unnecessarily
Connections {
@@ -331,6 +345,7 @@ Variants {
}
Component.onDestruction: {
LockKeysService.unregisterComponent("osd:" + (modelData?.name || "unknown"));
if (typeof BrightnessService !== "undefined" && BrightnessService.monitors) {
for (var i = 0; i < BrightnessService.monitors.length; i++) {
try {