% chktex-file 8

%\usepackage{fontawesome}
%\usepackage{fitbox}
%\usepackage{varwidth}
%\usepackage[breakable,listings,minted,raster,skins]{tcolorbox}

%%% Default titles %%%

\newcommand{\kvnotetitle}{Kernel Version Note}
\newcommand{\dontdothistitle}{Don't do this}
\newcommand{\importanttitle}{Very Important}
\newcommand{\infotitle}{Please Note}
\newcommand{\howitworkstitle}{How it works}
\newcommand{\questiontitle}{Question}
\newcommand{\configtitle}{make menuconfig}
\newcommand{\gittitle}{You could also get this upstream from git}
\newcommand{\videotitle}{Video Demonstration Resources}
\newcommand{\webtitle}{On the Web}
\newcommand{\clititle}{On the command line}
\newcommand{\shtitle}{Shell code}
\newcommand{\pytitle}{Python code}
\newcommand{\javatitle}{Java code}
\newcommand{\laptoptitle}{On Your Laptop}
\newcommand{\servertitle}{On Your Server}
\newcommand{\vmtitle}{On Your Virtual Machine}
\newcommand{\hosttitle}{On Linux Host Machine}
\newcommand{\targettitle}{On Embedded Target}
\newcommand{\serialtitle}{On the Serial Console}
\newcommand{\containertitle}{On Container}

\newcommand{\archlinuxtitle}{On Arch Linux}
\newcommand{\centostitle}{On CentOS}
\newcommand{\debiantitle}{On Debian}
\newcommand{\debianfamilytitle}{On Debian, Ubuntu, or Linux Mint}
\newcommand{\fedoratitle}{On Fedora}
\newcommand{\gentootitle}{On Gentoo}
\newcommand{\linuxminttitle}{On Linux Mint}
\newcommand{\redhattitle}{On RedHat}
\newcommand{\redhatfamilytitle}{On RedHat, Centos, or Fedora}
\newcommand{\rpmfamilytitle}{On RedHat, Centos, Fedora, or openSUSE}
\newcommand{\opensusetitle}{On openSUSE}
\newcommand{\ubuntutitle}{On Ubuntu}

%%% Default colors %%%

\newcommand{\lfboxcolor}{gray}
\newcommand{\kvnotecolor}{gray}
\newcommand{\dontdothiscolor}{red}
\newcommand{\importantcolor}{orange}
\newcommand{\infocolor}{blue}
\newcommand{\howitworkscolor}{blue}
\newcommand{\questioncolor}{purple}
\newcommand{\configcolor}{gray}
\newcommand{\gitcolor}{orange}
\newcommand{\videocolor}{teal}
\newcommand{\webcolor}{gray}
\newcommand{\clicolor}{red}
\newcommand{\shcolor}{blue}
\newcommand{\laptopcolor}{yellow}
\newcommand{\servercolor}{violet}
\newcommand{\vmcolor}{blue}
\newcommand{\hostcolor}{red}
\newcommand{\targetcolor}{green}
\newcommand{\serialcolor}{green}
\newcommand{\yamlcolor}{blue}
\newcommand{\pythoncolor}{gray}
\newcommand{\jsoncolor}{gray}
\newcommand{\javacolor}{gray}
\newcommand{\filecolor}{gray}
\newcommand{\ccolor}{blue}
\newcommand{\fdtcolor}{gray}
\newcommand{\latexcolor}{gray}
\newcommand{\makecolor}{orange}
\newcommand{\containercolor}{LFGreen}

%%% Default icons %%%

\newcommand{\kvnoteicon}{tux}
\newcommand{\dontdothisicon}{dontdothis}
\newcommand{\importanticon}{important}
\newcommand{\infoicon}{info}
\newcommand{\howitworksicon}{eureka}
\newcommand{\questionicon}{question}
\newcommand{\configicon}{config}
\newcommand{\giticon}{git}
\newcommand{\videoicon}{video}
\newcommand{\webicon}{www}
\newcommand{\cliicon}{cli}
\newcommand{\shicon}{script}
\newcommand{\laptopicon}{laptop}
\newcommand{\servericon}{server}
\newcommand{\vmicon}{vm}
\newcommand{\hosticon}{laptop}
\newcommand{\targeticon}{target}
\newcommand{\serialicon}{serial}
\newcommand{\fileicon}{file}
\newcommand{\cicon}{csrc}
\newcommand{\fdticon}{devicetree}
\newcommand{\latexicon}{latex}
\newcommand{\makeicon}{makefile}
\newcommand{\yamlicon}{yaml}
\newcommand{\pythonicon}{python}
\newcommand{\javaicon}{java}
\newcommand{\jsonicon}{json}
\newcommand{\containericon}{container}

\newcommand{\icon}[1]{common/IMAGES/icon-#1}
\newcommand{\videolink}[1]{\reslink{#1}}
\newcommand{\examplelink}[1]{\href{\currfiledir#1}{\texttt{#1}}}

% Adding a green version of alltt
\newenvironment{cmdtt}{\oldallttbegin\small\color{blue}}{\vspace{-10pt}\oldallttend}
\newenvironment{responsett}{\oldallttbegin\small\color{LFPurple}}{\vspace{-10pt}\oldallttend}

\newenvironment{vrbcode}
{\color{blue} \VerbatimEnvironment\begin{Verbatim}[frame=leftline,gobble=6,framerule=0mm,framesep=0mm,commandchars=\\\{\}]}
      {\end{Verbatim}}
\newenvironment{vrbans}
{\color{green!10!black} \VerbatimEnvironment\begin{Verbatim}[frame=leftline,gobble=6,framerule=0mm,framesep=0mm,commandchars=\\\{\}]}
      {\end{Verbatim}}

%%% Global tcolorbox settings %%%

% support TeXLive 2018 and 2019     

\def\TCBCOLBACK{tcbcolback}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%The below hacks now seem un-needed.  Creationline must have
%%had it wrong

%%\ifdefined\tcbcolback
%%\def\TCBCOLBACK{tcbcolback}
%%\else
%%\def\TCBCOLBACK{tcbcol@back}
%%\fi

%%%%\makeatletter
%%%%\ifthenelse{\equal{\tcb@version}{4.20} \OR \equal{\tcb@version}{4.21}}{
%%%%\def\TCBCOLBACK{tcbcolback}
%%%%}{
%%%%\def\TCBCOLBACK{tcbcol@back}
%%%%}
%%%%\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\tcbsetforeverylayer{
   enhanced,
   breakable,
   before skip=6mm,
   after skip=6mm,
   colback=black!5,
   colframe=black!50,
   boxrule=0.2mm,
   attach boxed title to top left={xshift=1cm,yshift*=1mm-\tcboxedtitleheight},
   varwidth boxed title*=-3cm,
   boxed title style={frame code={
               \path[fill=\TCBCOLBACK!30!black]
               ([yshift=-1mm,xshift=-1mm]frame.north west)
               arc[start angle=0,end angle=180,radius=1mm]
               ([yshift=-1mm,xshift=1mm]frame.north east)
               arc[start angle=180,end angle=0,radius=1mm];
               \path[left color=\TCBCOLBACK!60!black,right color=\TCBCOLBACK!60!black,
                  middle color=\TCBCOLBACK!80!black]
               ([xshift=-2mm]frame.north west) -- ([xshift=2mm]frame.north east)
               [rounded corners=1mm]-- ([xshift=1mm,yshift=-1mm]frame.north east)
               -- (frame.south east) -- (frame.south west)
               -- ([xshift=-1mm,yshift=-1mm]frame.north west)
               [sharp corners]-- cycle;
            },interior engine=empty,
      },
   fonttitle=\large\bfseries,
   parbox=false,
}

\newcommand{\iconleft}[1][empty]
{\node[anchor=north west,outer sep=-16pt] at (frame.north west)
   {\includegraphics[width=10mm]{\icon{#1}}};}

% iconbox [options]{title}{color}{icon}
\newtcolorbox{iconbox}[4][]
{title={#2},colbacktitle={#3},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{#4}}}; },#1}

% tabbox [options]{title}{color}{icon}
\newtcolorbox{tabbox}[4][]
{title={#2},colbacktitle={#3},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{#4}}}; },#1}

%%% Information boxes %%%

\renewtcolorbox{lfbox}[1][]
{title={#1},colbacktitle={\lfboxcolor}}

\renewtcolorbox{kvnote}[1][\kvnotetitle]
{title={#1},colbacktitle={\kvnotecolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\kvnoteicon}}}; }}

\newtcolorbox{dontdothis}[1][\dontdothistitle]
{title={#1},colbacktitle={\dontdothiscolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\dontdothisicon}}}; }}

\newtcolorbox{important}[1][\importanttitle]
{title={#1},colbacktitle={\importantcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\importanticon}}}; }}

\newtcolorbox{info}[1][\infotitle]
{title={#1},colbacktitle={\infocolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\infoicon}}}; }}

\newtcolorbox{howitworks}[1][\howitworkstitle]
{title={#1},colbacktitle={\howitworkscolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\howitworksicon}}}; }}

\newtcolorbox{question}[1][\questiontitle]
{title={#1},colbacktitle={\questioncolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\questionicon}}}; }}

\newtcolorbox{configbox}[1][\configtitle]
{title={#1},colbacktitle={\configcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\configicon}}}; }}

\newtcolorbox{gitbox}[1][\gittitle]
{title={#1},colbacktitle={\gitcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\giticon}}}; }}

\newtcolorbox{videobox}[1][\videotitle]
{title={#1},colbacktitle={\videocolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\videoicon}}}; }}

\newtcolorbox{webbox}[1][\webtitle]
{title={#1},colbacktitle={\webcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\webicon}}}; }}

%%% Context boxes for where things should be done %%%
% These use alltt environments so macros will be expanded,
% but otherwise a verbatim environment.

\newtcolorbox{filebox}[1][]
{title={#1},colbacktitle={\filecolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\fileicon}}}; }}

\newtcolorbox{cli}[1][\clititle]
{title={#1},colbacktitle={\clicolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\cliicon}}}; }}

\newtcolorbox{shbox}[1][\shtitle]
{title={#1},colbacktitle={\shcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\shicon}}}; }}

\newtcolorbox{onlaptop}[1][\laptoptitle]
{title={#1},colbacktitle={\laptopcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\laptopicon}}}; }}

\newtcolorbox{onserver}[1][\servertitle]
{title={#1},colbacktitle={\servercolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\servericon}}}; }}

\newtcolorbox{onvm}[1][\vmtitle]
{title={#1},colbacktitle={\vmcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\vmicon}}}; }}

\newtcolorbox{onhost}[1][\hosttitle]
{title={#1},colbacktitle={\hostcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\hosticon}}}; }}

\newtcolorbox{ontarget}[1][\targettitle]
{title={#1},colbacktitle={\targetcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\targeticon}}}; }}

\newtcolorbox{serialbox}[1][\serialtitle]
{title={#1},colbacktitle={\serialcolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\serialicon}}}; }}

\newtcolorbox{oncontainer}[1][\containertitle]
{title={#1},colbacktitle={\containercolor},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{\containericon}}}; }}

%%% Linux distributions %%%

\newtcolorbox{distro}[3][]
{title={#1},colbacktitle={#2},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{#3}}}; }}

\newcommand{\includeicon}[2][height=8mm]
{\includegraphics[#1]{\icon{#2}}}

\newtcolorbox{archlinuxbox}[1][]
{title={\archlinuxtitle\space #1},colbacktitle={teal},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{arch}}}; }}

\newcommand{\archlinuxicon}[1][height=8mm]{\includeicon[#1]{arch}}
\newcommand{\archlinux}[1][height=3mm]{\archlinuxicon[#1]\space \textbf{Arch Linux}}

\newtcolorbox{centosbox}[1][]
{title={\centostitle\space #1},colbacktitle={purple},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{centos}}}; }}

\newcommand{\centosicon}[1][height=8mm]{\includeicon[#1]{centos}}
\newcommand{\centos}[1][height=3mm]{\centosicon[#1]\space \textbf{CentOS}}

\newtcolorbox{debianbox}[1][]
{title={\debiantitle\space #1},colbacktitle={red},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{debian}}}; }}

\newcommand{\debianicon}[1][height=8mm]{\includeicon[#1]{debian}}
\newcommand{\debian}[1][height=3mm]{\debianicon[#1] \textbf{Debian}}

\newtcolorbox{debianfamilybox}[1][\debianfamilytitle]
{title={#1},colbacktitle={red},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{debian}}}; }}

\newcommand{\debianfamilyicons}[1][height=8mm]{\includeicon[#1]{debian-family-landscape}}
\newcommand{\debianfamily}[1][height=3mm]{\debian[#1], \ubuntu[#1], or \linuxmint[#1]}

\newtcolorbox{fedorabox}[1][]
{title={\fedoratitle\space #1},colbacktitle={blue!10!black},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{fedora}}}; }}

\newcommand{\fedoraicon}[1][height=8mm]{\includeicon[#1]{fedora}}
\newcommand{\fedora}[1][height=3mm]{\fedoraicon[#1]\space \textbf{Fedora}}

\newtcolorbox{gentoobox}[1][]
{title={\gentootitle\space #1},colbacktitle={violet!20!white},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{gentoo}}}; }}

\newcommand{\gentooicon}[1][height=8mm]{\includeicon[#1]{gentoo}}
\newcommand{\gentoo}[1][height=3mm]{\gentooicon[#1]\space \textbf{Gentoo}}

\newtcolorbox{linuxmintbox}[1][]
{title={\linuxminttitle\space #1},colbacktitle={green},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{linuxmint}}}; }}

\newcommand{\linuxminticon}[1][height=8mm]{\includeicon[#1]{linuxmint}}
\newcommand{\linuxmint}[1][height=3mm]{\linuxminticon[#1]\space \textbf{Linux Mint}}

\newtcolorbox{redhatbox}[1][]
{title={\redhattitle\space #1},colbacktitle={red},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{redhat}}}; }}

\newcommand{\redhaticon}[1][height=8mm]{\includeicon[#1]{redhat}}
\newcommand{\redhat}[1][height=3mm]{\redhaticon[#1]\space \textbf{RedHat}}
\newcommand{\rhel}[1][height=3mm]{\redhaticon[#1]\space \textbf{RHEL}}

\newtcolorbox{redhatfamilybox}[1][\redhatfamilytitle]
{title={#1},colbacktitle={red},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{redhat}}}; }}

\newcommand{\redhatfamilyicons}[1][height=8mm]{\includeicon[#1]{redhat-family-landscape}}
\newcommand{\redhatfamily}[1][height=3mm]{\redhat[#1], \centos[#1], or \fedora[#1]}

\newtcolorbox{rpmfamilybox}[1][\rpmfamilytitle]
{title={#1},colbacktitle={red},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{redhat}}}; }}

\newcommand{\rpmfamilyicons}[1][height=8mm]{\includeicon[#1]{rpm-family-landscape}}
\newcommand{\rpmfamily}[1][height=3mm]{\redhat[#1], \centos[#1], \fedora[#1] or \opensuse[#1]}

\newtcolorbox{opensusebox}[1][]
{title={\opensusetitle\space #1},colbacktitle={green},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{opensuse}}}; }}

\newcommand{\opensuseicon}[1][height=8mm]{\includeicon[#1]{opensuse}}
\newcommand{\opensuse}[1][height=3mm]{\opensuseicon[#1]\space \textbf{openSUSE}}
\newcommand{\suse}[1][height=3mm]{\opensuseicon[#1]\space \textbf{SUSE}}

\newtcolorbox{ubuntubox}[1][]
{title={\ubuntutitle\space #1},colbacktitle={orange},
   overlay={\node[anchor=north west,outer sep=-16pt] at (frame.north west)
         {\includegraphics[width=10mm]{\icon{ubuntu}}}; }}

\newcommand{\ubuntuicon}[1][height=8mm]{\includeicon[#1]{ubuntu}}
\newcommand{\ubuntu}[1][height=3mm]{\ubuntuicon[#1]\space \textbf{Ubuntu}}

\newcommand{\buildrooticon}[1][height=8mm]{\includeicon[#1]{buildroot}}
\newcommand{\buildroot}[1][height=3mm]{\buildrooticon[#1] \textbf{Buildroot}}

\newcommand{\openembeddedicon}[1][height=8mm]{\includeicon[#1]{oe}}
\newcommand{\openembedded}[1][height=3mm]{\openembeddedicon[#1] \textbf{OpenEmbedded}}

\newcommand{\yoctoprojecticon}[1][height=8mm]{\includeicon[#1]{yocto-project}}
\newcommand{\yoctoproject}[1][height=3mm]{\textbf{Yocto Project}}

%%% redfine all box titles fo spanish (if needed)  the list
%% was generate doing grep newcommand | grep title lf-boxes.tex
%% and minor editing

\ifdefined\SPANISH
   \input{spanishtitles}
\fi

\ifdefined\JAPANESE
   \input{japanesetitles}
\fi

%% listing macros
\input{lf-listings}
