Wrapper around the gsettings command line tool.
npm install node-gsettings-wrapper --save
const GSettings = require("node-gsettings-wrapper");
// Check if GSettings is available:
if (!GSettings.isAvailable()) {
console.log("The gsettings command line tool is not available.");
process.exit(1);
}
// Get a schema by ID:
const schema = GSettings.Schema.findById("org.gnome.desktop.interface");
// Get a key of a schema by ID:
let animationsKey = schema.findKeyById("enable-animations");
// Other way to get a key:
animationsKey = GSettings.Key.findById(
"org.gnome.desktop.interface", "enable-animations");
// Display the value of a key:
console.log("enable-animations: " + animationsKey.getValue());
// Monitor a key for value changes:
const removeKeyListener = animationsKey.addListener((key, value) => {
console.log("New value: " + value);
});
// Terminate key monitoring after 5 seconds:
setTimeout(removeKeyListener, 5000);