Skip to content

Instantly share code, notes, and snippets.

@JumpLink
Created July 19, 2014 11:54
Show Gist options
  • Save JumpLink/3da5d8df42316fbb0617 to your computer and use it in GitHub Desktop.
Save JumpLink/3da5d8df42316fbb0617 to your computer and use it in GitHub Desktop.
org.freedesktop.NetworkManager.Settings.Connection Update
var DBus = require('dbus');
var dbus = new DBus();
var util = require('util');
var inspect = function(object) {
console.log("\n"+util.inspect(object, showHidden=false, depth=2, colorize=true)+"\n");
}
var bus = dbus.getBus('system');
var serviceName = 'org.freedesktop.NetworkManager';
var objectPath = '/org/freedesktop/NetworkManager/Settings/0'; // replace the number 0 this with your settings you want to test, you can use d-feet to pick up the right
var interfaceName = 'org.freedesktop.NetworkManager.Settings.Connection';
bus.getInterface(serviceName, objectPath, interfaceName, function(err, iface) {
var getSettings = function (callback) {
iface.GetSettings['error'] = function (error) {
inspect(error);
callback(error, null);
};
iface.GetSettings['finish'] = function (settings) {
inspect(settings);
callback(null, settings);
};
iface.GetSettings();
}
var update = function (settings, callback) {
iface.Update['error'] = function (error) {
inspect(error);
callback(error);
};
iface.Update['finish'] = function () {
inspect("updated");
callback(null);
};
iface.Update(settings);
}
getSettings(function (error, settings) {
update(settings, function (error) {
// error === "[Error: org.freedesktop.NetworkManager.Settings.Connection.MissingProperty]"
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment