Skip to content

Commit

Permalink
Merge pull request #97 from deenter/dark_mode
Browse files Browse the repository at this point in the history
Add option to enable browser dark mode
  • Loading branch information
sibbl committed Dec 2, 2023
2 parents 56ef990 + 6364bf1 commit 22e648d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Home Assistant related stuff:
| `HA_ACCESS_TOKEN` | `eyJ0...` | yes | no | Long-lived access token from Home Assistant, see [official docs](https://developers.home-assistant.io/docs/auth_api/#long-lived-access-token) |
| `HA_BATTERY_WEBHOOK` | `set_kindle_battery_level` | no | yes | Webhook definied in HA which receives `batteryLevel` (number between 0-100) and `isCharging` (boolean) as JSON |
| `LANGUAGE` | `en` | no | no | Language to set in browser and home assistant |
| `PREFERS_COLOR_SCHEME` | `light` | no | no | Enable browser dark mode, use `light` or `dark`. |
| `CRON_JOB` | `* * * * *` | no | no | How often to take screenshot |
| `RENDERING_TIMEOUT` | `10000` | no | no | Timeout of render process, helpful if your HASS instance might be down |
| `RENDERING_DELAY` | `0` | no | yes | how long to wait between navigating to the page and taking the screenshot, in milliseconds |
Expand Down
1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function getPagesConfig() {
whiteLevel: getEnvironmentVariable("WHITE_LEVEL", suffix) || "100%",
dither: getEnvironmentVariable("DITHER", suffix) || false,
colorMode: getEnvironmentVariable("COLOR_MODE", suffix) || "GrayScale",
prefersColorScheme: getEnvironmentVariable("PREFERS_COLOR_SCHEME", suffix) || "light",
rotation: getEnvironmentVariable("ROTATION", suffix) || 0,
scaling: getEnvironmentVariable("SCALING", suffix) || 1,
batteryWebHook: getEnvironmentVariable("HA_BATTERY_WEBHOOK", suffix) || null,
Expand Down
2 changes: 2 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ options:
SCALING: '1'
GRAYSCALE_DEPTH: '8'
COLOR_MODE: 'GrayScale'
PREFERS_COLOR_SCHEME: 'light'
HA_BATTERY_WEBHOOK: ''
schema:
HA_BASE_URL: "url"
Expand All @@ -52,6 +53,7 @@ schema:
SCALING: "int"
GRAYSCALE_DEPTH: "int"
COLOR_MODE: "list(GrayScale|TrueColor)?"
PREFERS_COLOR_SCHEME: "list(light|dark)?"
HA_BATTERY_WEBHOOK: "str"
environment:
output_path: "/output/cover.png"
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ async function renderUrlToImageAsync(browser, pageConfig, url, path) {
await page.emulateMediaFeatures([
{
name: "prefers-color-scheme",
value: "light"
value: `${pageConfig.prefersColorScheme}`
}
]);

Expand Down

0 comments on commit 22e648d

Please sign in to comment.