I’m working on making a script with node.js for setting up my dzen2 in i3, and haven’t really used node for anything like this before.
I need the geometry of the screen to start with, which I can get with something like this:
geometry = getGeo();
function getGeo() {
var sh = require('child_process').exec("i3-msg -t get_outputs",
function(error, stdout, stderr) {
var out = JSON.parse(stdout);
return out[0].rect; //this is the geometry, {"x":0, "y":0, "width":1280, "height":768}
});
};
console.log(geometry);
console.log is logging undefined.
I’m not sure what the proper way to do this is, my brain is tired.
You can’t return from the callback function since is async.
Rather write another function and pass the callback object to it.