Merge pull request #36 from icepie/master

提升 Gnome 桌面下跟随系统浅暗色主题的功能
This commit is contained in:
msojocs 2022-04-10 16:02:04 +08:00 committed by GitHub
commit 2f18e2a178
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,13 +16,22 @@ class CheckDark {
break;
case "gnome":
case "gnome-classic":
const gnomeVersion = execSync(`gnome-shell --version`).toString().replace(/[\r\n]/g, "").split(" ")
const gnomeVersionNum = gnomeVersion.length == 3 ? Number(gnomeVersion[2]) : 0
if (gnomeVersionNum >= 42) {
monitor = spawn("gsettings", [
"monitor",
"org.gnome.desktop.interface",
"color-scheme",
]);
} else {
monitor = spawn("gsettings", [
"monitor",
"org.gnome.desktop.interface",
"gtk-theme",
]);
}
break;
default:
console.warn(
`NOT SUPPORTED !!! DESKTOP_SESSION: ${DESKTOP_SESSION}`
@ -37,7 +46,7 @@ class CheckDark {
monitor.stdout.on("data", (chunk) => {
// TODO: 防抖动包装
const data = chunk.toString();
const t = data.includes("dark");
const t = data.includes("dark") || data.includes("Dark");
console.log(data);
console.log("dark", t);
// (this._theme = t ? i.Dark : i.Light),
@ -56,15 +65,24 @@ class CheckDark {
break;
case "gnome":
case "gnome-classic":
// 判断 Gnome-Shell 版本
const gnomeVersion = execSync(`gnome-shell --version`).toString().replace(/[\r\n]/g, "").split(" ")
const gnomeVersionNum = gnomeVersion.length == 3 ? Number(gnomeVersion[2]) : 0
if (gnomeVersionNum >= 42) {
theme = execSync(
`gsettings get org.gnome.desktop.interface color-scheme`
);
} else {
theme = execSync(
`gsettings get org.gnome.desktop.interface gtk-theme`
);
}
break;
default:
break;
}
return theme.includes("dark");
return theme.includes("dark") || theme.includes("Dark");
}
}
const cd = new CheckDark();