Skip to content

Commit 557294a

Browse files
authored
Merge pull request #4 from timrogers/timrogers/cli
feat: add `litra-on` and `litra-off` CLI tools for turning your light on and off
2 parents a97c004 + 5cf52e1 commit 557294a

File tree

12 files changed

+102
-10
lines changed

12 files changed

+102
-10
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,36 @@
11
# Logitech Litra Glow
22

3-
This JavaScript library allows you to control your [Logitech Litra Glow](https://www.logitech.com/en-gb/products/lighting/litra-glow.946-000002.html) light programatically.
3+
This JavaScript driver allows you to control your [Logitech Litra Glow](https://www.logitech.com/en-gb/products/lighting/litra-glow.946-000002.html) light using a CLI and from your JavaScript code.
44

55
With this driver, you can:
66

77
* Turn your light on and off
88
* Set the brightness of your light
99
* Set the temperature of your light
1010

11-
## Compatability
11+
## Compatibility
1212

1313
This library is only tested on macOS Monterey (12.5). It's powered by [`node-hid`](https://github.com/node-hid/node-hid), which is compatible with other macOS versions, Windows and Linux, so it would be expected to work there too, but your milage may vary 🙏
1414

15-
## Installation
15+
## Using as a command line tool
1616

17-
Simply add the `litra-glow` Node.js package to your `package.json`:
17+
Make sure you have Node.js available on your machine, and then install the package with `npm install -g litra-glow`.
18+
19+
With the package installed, use the `litra-on` and `litra-off` commands to turn your light on and off.
20+
21+
## Using as a JavaScript library
22+
23+
### Installation
24+
25+
Simply add the `litra-glow` Node.js package to your `package.json` and install it:
1826

1927
```sh
2028
npm install --save litra-glow
2129
```
2230

23-
## Usage
31+
### Usage
2432

25-
### Checking if a Litra Glow is plugged in
33+
#### Checking if a Litra Glow is plugged in
2634

2735
The `findDevice` function checks your computer to find whether a Logitech Litra Glow is plugged in.
2836

@@ -36,7 +44,7 @@ const device = findDevice();
3644

3745
If you're a *huge* fan of the Litra Glow and you have multipled plugged in at the same time, it'll return whatever one it happens to find first.
3846

39-
### Turning your Litra Glow on or off
47+
#### Turning your Litra Glow on or off
4048

4149
Find your device with `findDevice`, and then use the simple `turnOn` and `turnOff` functions. They just take one parameter: the device.
4250

@@ -50,7 +58,7 @@ turnOn(device);
5058
setTimeout(() => turnOff(device), 5000));
5159
```
5260

53-
### Setting the brightness of your Litra Glow
61+
#### Setting the brightness of your Litra Glow
5462

5563
You can set the brightness of your Litra Glow, measured in Lumen, using the `setBrightnessInLumen` function. The Litra Glow supports brightness between 20 and 250 Lumen:
5664

@@ -72,7 +80,7 @@ const device = findDevice();
7280
setBrightnessPercentage(device, 75);
7381
```
7482

75-
### Setting the temperature of your Litra Glow
83+
#### Setting the temperature of your Litra Glow
7684

7785
You can set the temperature of your Litra Glow, measured in Kelvin, using the `setTemperatureInKelvin` function. The Litra Glow supports temperature between 2700 and 6500 Kelvin:
7886

dist/commonjs/cli/litra-off.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
export {};

dist/commonjs/cli/litra-off.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
4+
const driver_1 = require("./../driver");
5+
try {
6+
const device = (0, driver_1.findDevice)();
7+
(0, driver_1.turnOff)(device);
8+
process.exit(0);
9+
}
10+
catch (e) {
11+
console.log(e);
12+
process.exit(1);
13+
}

dist/commonjs/cli/litra-on.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
export {};

dist/commonjs/cli/litra-on.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env node
2+
"use strict";
3+
Object.defineProperty(exports, "__esModule", { value: true });
4+
const driver_1 = require("./../driver");
5+
try {
6+
const device = (0, driver_1.findDevice)();
7+
(0, driver_1.turnOn)(device);
8+
process.exit(0);
9+
}
10+
catch (e) {
11+
console.log(e);
12+
process.exit(1);
13+
}

dist/esm/cli/litra-off.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
export {};

dist/esm/cli/litra-off.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
import { findDevice, turnOff } from './../driver';
3+
try {
4+
const device = findDevice();
5+
turnOff(device);
6+
process.exit(0);
7+
}
8+
catch (e) {
9+
console.log(e);
10+
process.exit(1);
11+
}

dist/esm/cli/litra-on.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
export {};

dist/esm/cli/litra-on.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env node
2+
import { findDevice, turnOn } from './../driver';
3+
try {
4+
const device = findDevice();
5+
turnOn(device);
6+
process.exit(0);
7+
}
8+
catch (e) {
9+
console.log(e);
10+
process.exit(1);
11+
}

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "litra-glow",
33
"version": "0.0.0-development",
4-
"description": "A JavaScript package, including TypeScript types, for programatically controlling your Logitech Litra Glow light",
4+
"description": "A driver for controlling your Logitech Litra Glow light from a CLI or your JavaScript code",
55
"main": "./dist/commonjs/driver.js",
66
"module": "./dist/esm/driver.js",
77
"homepage": "https://github.com/timrogers/litra-glow",
@@ -42,5 +42,9 @@
4242
},
4343
"release": {
4444
"branches": ["main"]
45+
},
46+
"bin": {
47+
"litra-on": "./dist/commonjs/cli/litra-on.js",
48+
"litra-off": "./dist/commonjs/cli/litra-off.js"
4549
}
4650
}

0 commit comments

Comments
 (0)