Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,14 @@
"name": "Command Exec Button",
"address": "41:02:dc:b2:10:12",
"cmd": "/home/user/dash_button.sh"
},
{
"name": "WOL Button",
"address": "41:02:dc:b2:10:1f",
"cmd": "etherwake",
"args": [
"AA:AA:AA:BB:BB:BB",
"CC:CC:CC:DD:DD:DD"
]
}
]}
8 changes: 4 additions & 4 deletions lib/dasher.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function DasherButton(button) {
doLog("Debug mode, skipping request.");
console.log(button);
} else if (typeof button.cmd !== 'undefined' && button.cmd != "") {
doCommand(button.cmd, button.name)
doCommand(button.cmd, button.args)
} else {
doRequest(button.url, button.method, options)
}
Expand All @@ -35,12 +35,12 @@ function DasherButton(button) {
doLog(button.name + " added.")
}

function doCommand(command, name, callback) {
const child = execFile(command, [name], (error, stdout, stderr) => {
function doCommand(command, args, callback) {
const child = execFile(command, args, (error, stdout, stderr) => {
if (error) {
// Stripping a trailing new line
output = stderr.replace (/\s+$/g, "");
doLog(`There was an error: ${output}`);
doLog(`There was an error: ${output}`);
}

if (stdout != "") {
Expand Down