-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmediakeys
More file actions
executable file
·32 lines (25 loc) · 786 Bytes
/
Copy pathmediakeys
File metadata and controls
executable file
·32 lines (25 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env node
var mediakeys = require('mediakeys').listen();
var spawn = require("child_process").spawn;
function send_command(command){
var cmus_remote = spawn("cmus-remote", ["-C"].concat(command));
cmus_remote.stdout.on("data", function (data) {
console.log("stdout: " + data, "stdout");
});
cmus_remote.stderr.on("data", function (data) {
console.log("stderr: " + data, "warning");
});
cmus_remote.on("close", function (code) {});
}
mediakeys.on('play', function () {
console.log('player play/pause');
send_command('player-pause');
})
mediakeys.on('next', function () {
console.log('player next');
send_command('player-next');
})
mediakeys.on('back', function () {
console.log('player back');
send_command('player-prev');
})