Skip to content

Commit

Permalink
Updated to v2. Based on feedback of the 'GNOME Shell Extensions' review
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenSeifried committed Dec 30, 2024
1 parent 996c453 commit 8c17693
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
15 changes: 5 additions & 10 deletions [email protected]/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class FnLockExtension extends Extension {
try {
return GLib.file_get_contents(FN_LOCK_PATH)[1].toString().trim();
} catch (e) {
logError(`Error reading fn_lock state: ${e}`);
console.error(`Error reading fn_lock state: ${e}`);
return null;
}
}
Expand All @@ -34,7 +34,7 @@ export default class FnLockExtension extends Extension {
GLib.file_set_contents(FN_LOCK_PATH, state);
return true;
} catch (e) {
logError(`Error writing fn_lock state: ${e}`);
console.error(`Error writing fn_lock state: ${e}`);
return false;
}
}
Expand All @@ -51,20 +51,15 @@ export default class FnLockExtension extends Extension {
}

// Log the current state for debugging
log(`Current fn_lock state: ${state}`);
console.log(`Current fn_lock state: ${state}`);
}

switch_fnlock() {
const currentState = this._readFnLockState();
if (currentState !== null) {
const newState = currentState === "1" ? "0" : "1";
if (this._writeFnLockState(newState)) {
log(`Switched fn_lock state to: ${newState}`);
// Add a small delay before updating the icon
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100, () => {
this.update_fnlock();
return GLib.SOURCE_REMOVE;
});
console.log(`Switched fn_lock state to: ${newState}`);
}
}
}
Expand Down Expand Up @@ -105,7 +100,7 @@ export default class FnLockExtension extends Extension {
const file = Gio.File.new_for_path(FN_LOCK_PATH);
this._fileMonitor = file.monitor_file(Gio.FileMonitorFlags.NONE, null);
this._fileMonitor.connect("changed", () => {
log("File monitor detected change");
console.log("File monitor detected change");
this.update_fnlock();
});

Expand Down
4 changes: 2 additions & 2 deletions [email protected]/metadata.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"description": "Show the FnLock status of TUXEDO devices",
"description": "Show the FnLock status of TUXEDO devices. This extension is not affiliated, funded, or in any way associated with TUXEDO. This extension is a fork of the 'FnLock switch (ThinkPad Compact USB Keyboard)' extension.",
"name": "TUXEDO FnLock status",
"shell-version": ["47"],
"url": "https://github.com/StevenSeifried/tuxedo-fnlock-status",
"uuid": "[email protected]",
"settings-schema": "org.gnome.shell.extensions.tuxedo-fnlock-status",
"version": 1
"version": 2
}

0 comments on commit 8c17693

Please sign in to comment.