Skip to content

Instantly share code, notes, and snippets.

View ar-nelson's full-sized avatar

Adam R. Nelson ar-nelson

View GitHub Profile
@ar-nelson
ar-nelson / event_reader.js
Created August 24, 2013 20:57
Simple node.js script that prints wmii events as they occur.
var spawn = require('child_process').spawn;
var stdin = process.openStdin();
var reader = spawn('wmiir', ['read', '/event']);
reader.stdout.on('data', function(data) {
console.log("Got event: " + data);
});
console.log("Press ENTER to exit.");
@ar-nelson
ar-nelson / wmiir.fragment.js
Last active December 21, 2015 15:59
The first two functions of my node.js library for wmiir. Used in my blog.
var spawn = require('child_process').spawn;
// Spawns and returns a child process that runs `wmiir read`.
// The callback takes two parameters: (err, line).
// It is called once for each line in the file read.
// - err is any error that occurred, or null if no error occurred.
// - line is the last line read from the file.
exports.read = function(path, callback) {
// Start the process.
var child = spawn('wmiir', ['read', path]);
@ar-nelson
ar-nelson / wmiir.js
Last active December 21, 2015 15:59
Completed node.js wmiir convenience library.
// wmiir controller module
// Adam R. Nelson
// August 2013
var spawn = require('child_process').spawn;
// Spawns and returns a child process that runs `wmiir read`.
// The callback takes two parameters: (err, line).
// It is called once for each line in the file read.
// - err is any error that occurred, or null if no error occurred.