Skip to content

Commit

Permalink
Force DevTools to darkmode
Browse files Browse the repository at this point in the history
  • Loading branch information
IzKuipers committed Oct 14, 2024
1 parent 72085b5 commit 1264f32
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { app, BrowserWindow, globalShortcut, webContents } from "electron";
import { VERSION } from "./src/env.js";
import remote from "@electron/remote/main/index.js";
import { app, BrowserWindow, globalShortcut, nativeTheme } from "electron";
import { VERSION } from "./src/env.js";

remote.initialize();
// remote.enable(webContents);

let window;

Expand Down Expand Up @@ -36,6 +35,10 @@ app.on("ready", () => {
});
});

window.webContents.on("devtools-opened", () => {
toggleNativeTheme();
});

window.webContents.session.webRequest.onHeadersReceived(
{ urls: ["*://*/*"] },
(d, c) => {
Expand All @@ -57,3 +60,13 @@ app.on("ready", () => {
if (window.isFocused()) window.fullScreen = !window.fullScreen;
});
});

function toggleNativeTheme() {
// First, set the theme to 'light'
nativeTheme.themeSource = "light";

// After a short delay, set it to 'dark'
setTimeout(() => {
nativeTheme.themeSource = "dark";
}, 100); // 100ms delay; adjust if necessary
}

0 comments on commit 1264f32

Please sign in to comment.