0.5.0 • Published 7 years ago

node-gsettings-wrapper v0.5.0

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

node-gsettings-wrapper

NPM version Build Status Coverage Status

Wrapper around the gsettings command line tool.

Installation

npm install node-gsettings-wrapper --save

Basic Usage

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);
}

// Display all available schemas:
GSettings.Schema.getAll().forEach((schema) => {
  console.log(schema.getId());
});

// Display all keys of a schema:
GSettings.Schema.findById("org.gtk.Demo").getKeys().forEach((key) => {
  console.log(key.getId());
});

// Display the value of a key:
const colorKey = GSettings.Key.findById("org.gtk.Demo", "color");
console.log(colorKey.getValue());

// Monitor a key for value changes:
const removeKeyListener = colorKey.addListener((key, value) => {
  console.log("New value: " + value);
});

// Terminate key monitoring after 5 seconds:
setTimeout(removeKeyListener, 5000);

// Monitor a schema for changes:
const removeSchemaListener = schema.addListener((key, value) => {
  console.log("New value: " + key.getId() + ": " + value);
});

// Terminate schema monitoring after 5 seconds:
setTimeout(removeSchemaListener, 5000);

// Display the values of all keys:
GSettings.Schema.getAll().forEach((schema) => {
  console.log(schema.getId());
  schema.getKeys().forEach((key) => {
    console.log(" - " + key.getId() + ": " + key.getValue());
  });
});

Roadmap

VersionPlanned Features
0.6.xSet the value of a key. Set the value of a key to the default value.
1.0.0Support all gsettings commands and options.