%%
%% This is file `darkmode.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% darkmode.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2022 by Ruben Deisenroth <rdeisenroth@gmail.com>
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3 of this license or (at your option) any later
%% version. The latest version of this license is in:
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3 or later is part of all distributions of
%% LaTeX version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\RequirePackage{expl3,l3keys2e}
\ProvidesExplPackage {darkmode} {2022-09-01} {1.0.1}
{Provide general dark mode support for any LaTeX document.}

\RequirePackage{xcolor,pagecolor}
\keys_define:nn {darkmode} {
    enable .bool_gset:N = \g_@@_dark_mode_bool,
    enable .initial:n = false,
    enable .default:n = true,
    defaulthook .bool_gset:N = \g_@@_dark_mode_hook_bool,
    defaulthook .initial:n = true,
    defaulthook .default:n = true,
    nodefaulthook .meta:n = {defaulthook=false},
}
\ProcessKeysOptions{darkmode}

\prg_new_conditional:Nnn \__darkmode_if_dark_mode: {T,F,TF} {
    \bool_if:NTF \g_@@_dark_mode_bool
    {\prg_return_true:}
    {\prg_return_false:}
}
\cs_set_eq:NN\IfDarkModeT \__darkmode_if_dark_mode:T
\cs_set_eq:NN\IfDarkModeF \__darkmode_if_dark_mode:F
\cs_set_eq:NN\IfDarkModeTF \__darkmode_if_dark_mode:TF
\definecolor{darkmode@anthrazitgrau}{HTML}{293133}
\colorlet{fgcolor}{.}
\DeclareDocumentCommand{\@darkmode@set@enabled}{}{
    \bool_set_true:c {g_@@_dark_mode_bool}
}
\DeclareDocumentCommand{\@darkmode@on@enable}{}{
    \pagecolor{darkmode@anthrazitgrau}
    \color{white}
    \selectcolormodel{RGB}
    \colorlet{fgcolor}{.}
}
\DeclareDocumentCommand{\enabledarkmode}{}{
    \@darkmode@set@enabled
    \bool_if:cT {g_@@_dark_mode_hook_bool} {\@darkmode@on@enable}
}
\DeclareDocumentCommand{\@darkmode@set@disabled}{}{
    \bool_set_false:c {g_@@_dark_mode_bool}
}
\DeclareDocumentCommand{\@darkmode@on@disable}{}{
    \pagecolor{white}
    \color{black}
    \colorlet{fgcolor}{.}
}
\DeclareDocumentCommand{\disabledarkmode}{}{
    \@darkmode@set@disabled
    \bool_if:cT {g_@@_dark_mode_hook_bool} {\@darkmode@on@disable}
}
\DeclareDocumentCommand{\__darkmode_update_from_bool}{}{
    \IfDarkModeTF{\enabledarkmode}{\disabledarkmode}
}
\__darkmode_update_from_bool
\endinput
%%
%% End of file `darkmode.sty'.
