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 / 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.
@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 / 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 / hello.js
Created August 24, 2013 21:24
Hello, world!
console.log('Hello, world!');
@ar-nelson
ar-nelson / wmii_events.js
Last active December 21, 2015 15:59
node.js EventEmitter wrapper for the wmii event loop.
// wmii event handler module
// Adam R. Nelson
// August 2013
var events = require('events');
var util = require('util');
var wmiir = require('./wmiir.js');
function WmiiEvents() {
@ar-nelson
ar-nelson / key_events.js
Created August 24, 2013 23:17
Uses wmii_events.js to listen for wmii keypress events.
var events = require('./wmii_events.js');
var stdin = process.openStdin();
events.on('Key', function(key) {
console.log('Keypress: ' + key);
});
console.log("Press ENTER to exit.");
stdin.on('data', function(data) {
@ar-nelson
ar-nelson / wmii_keys.js
Last active December 21, 2015 23:59
wmii keyboard events handler for node.js. Depends on wmiir.js and wmii_events.js.
// wmii keybindings and keyboard event module
// Adam R. Nelson
// August 2013
var wmiir = require('./wmiir.js');
var events = require('./wmii_events.js');
var globalKeys = {};
var modeKeys = {};
var currentMode = null;
@ar-nelson
ar-nelson / dialog.js
Created August 30, 2013 06:09
node.js module that displays Zenity dialog boxes.
// zenity dialog box functions
// Adam R. Nelson
// August 2013
var spawn = require('child_process').spawn;
function appendSettings(args, settings) {
if (settings) {
if (settings.ok) {
args.push('--ok-label');
@ar-nelson
ar-nelson / wmii.1.js
Created September 14, 2013 18:21
Initial skeleton version of the core wmii config node.js module.
// wmii core Module
// Adam R. Nelson
// August 2013
var wmiir = require('./wmiir.js');
var events = require('./wmii_events.js');
var keys = require('./wmii_keys.js');
var dialog = require('./dialog.js');
var spawn = require('child_process').spawn;
@ar-nelson
ar-nelson / wmiirc.1.js
Created September 14, 2013 20:07
Initial skeleton version of wmiirc.js, the user-modifiable configuration file for my node.js wmii config.
var dialog = require('./lib/dialog.js');
var wmii = require('./lib/wmii.js');
var wmiir = require('./lib/wmiir.js');
var modkey = 'Mod4';
var terminal = 'urxvt';
function attachModKey(mode) {
var newMode = {};
for (var key in mode) {