fix(lock-keys): sync bar state from sysfs on first poll after startup

This commit is contained in:
Lysec
2026-03-23 15:30:26 +01:00
parent 2ea56a6c1f
commit 284a2a76bb
+19 -6
View File
@@ -35,9 +35,6 @@ Singleton {
signal numLockChanged(bool active)
signal scrollLockChanged(bool active)
// Flag to track if this is the initial check to avoid OSD triggers
property bool initialCheckDone: false
Instantiator {
model: FolderListModel {
id: folderModel
@@ -52,13 +49,29 @@ Singleton {
onTextChanged: () => {
if (!this.isWanted)
return;
var state = !this.text().startsWith("0");
var kind = fileName.split("::")[1];
// First read after polling starts: sync bar/UI from sysfs without firing
// *Changed signals (OSD listens to those and would flash on startup).
if (!this.initialCheckDone) {
this.initialCheckDone = true;
switch (kind) {
case "numlock":
root.numLockOn = state;
break;
case "capslock":
root.capsLockOn = state;
break;
case "scrolllock":
root.scrollLockOn = state;
break;
}
return;
}
var state = !this.text().startsWith("0");
switch (fileName.split("::")[1]) {
switch (kind) {
case "numlock":
root.numLockOn = state;
root.numLockChanged(state);
@@ -91,7 +104,7 @@ Singleton {
return false;
}
// Skip first OSD event if one fires immediately after enabling
// After shouldRun becomes true, first brightness read updates properties only (no *Changed signals).
property bool initialCheckDone: false
property variant connections: Connections {
target: root