Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for xbacklight on Linux #11

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 24 additions & 0 deletions lib/linux-xbacklight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
var xbacklight = require('xbacklight');
var Promise = require('pinkie-promise');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed as this module targets Node.js 4 now.


function get() {
return new Promise(function (resolve, reject) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to wrap a promise in another promise.

xbacklight.get()
.then(function (val) {
resolve(val / 100);
})
.catch(function (err) {
reject(err);
});
});
}

function set(val) {
return xbacklight.set(val * 100);
}

module.exports = {
isInstalledSync: xbacklight.isInstalledSync,
get: get,
set: set
};
7 changes: 7 additions & 0 deletions lib/linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ var fs = require('fs');
var path = require('path');
var pify = require('pify');
var Promise = require('pinkie-promise');
var linuxXbacklight = require('./linux-xbacklight');

if (linuxXbacklight.isInstalledSync()) {
module.exports = linuxXbacklight;
return;
}

var fsP = pify(fs, Promise);

module.exports.get = function () {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"osx-brightness": "^4.0.0",
"pify": "^2.3.0",
"pinkie-promise": "^2.0.0",
"wmi-client": "^0.2.0"
"wmi-client": "^0.2.0",
"xbacklight": "^1.0.1"
},
"devDependencies": {
"ava": "*",
Expand Down