qutebrowser: remeber dark theme preference

This commit is contained in:
Leonardo Eugênio 2023-05-12 12:11:46 -03:00
parent d32bd28650
commit f1cbae7b53
4 changed files with 107 additions and 71 deletions

View file

@ -158,75 +158,20 @@ in
# Dark theme
########################################################
webpage = lib.mkIf (color.type == "dark") {
bg = color.bg;
preferred_color_scheme = "dark";
darkmode = {
enabled = false;
threshold = {
text = 150;
background = 205;
};
};
};
# webpage = lib.mkIf (color.type == "dark") {
# bg = color.bg;
# preferred_color_scheme = "dark";
# darkmode = {
# enabled = false;
# threshold = {
# text = 150;
# background = 205;
# };
# };
# };
};
};
home.file = {
# For some stupid reason qutebrowser crashes if this dir does not exist
".config/qutebrowser/greasemonkey/darkreader.js".text = ''
// ==UserScript==
// @name Dark Reader (Unofficial)
// @icon https://darkreader.org/images/darkreader-icon-256x256.png
// @namespace DarkReader
// @description Inverts the brightness of pages to reduce eye strain
// @version 4.7.15
// @author https://github.com/darkreader/darkreader#contributors
// @homepageURL https://darkreader.org/ | https://github.com/darkreader/darkreader
// @run-at document-end
// @grant none
// @include http*
// @require https://cdn.jsdelivr.net/npm/darkreader/darkreader.min.js
// @noframes
// ==/UserScript==
DarkReader.setFetchMethod(window.fetch)
if ("${color.type}" != "dark") {
DarkReader.disable();
return;
}
const ignore_list = [
"askubuntu.com",
"mathoverflow.com",
"mathoverflow.net",
"serverfault.com",
"stackapps.com",
"stackexchange.com",
"stackoverflow.com",
"superuser.com",
"hub.docker.com",
];
for (let item of ignore_list) {
if (window.location.origin.indexOf(item) >= 0) {
console.log("URL matched dark-mode ignore list");
return;
}
}
DarkReader.enable({
brightness: 100,
contrast: 100,
sepia: 0,
darkSchemeBackgroundColor: "${color.bg}",
darkSchemeTextColor: "${color.txt}",
lightSchemeBackgroundColor: "${color.bg}",
lightSchemeTextColor: "${color.txt}",
});
'';
".config/qutebrowser/style.css".text = ''
${lib.optionalString (color.type == "dark") ''
button,