From f5fc3d2c6f010988c211b854ef748db701cee5e4 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 23 May 2020 15:33:17 +0200 Subject: [PATCH] Add dark theme toggle --- config.org | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/config.org b/config.org index 76d467e..d120eca 100644 --- a/config.org +++ b/config.org @@ -1,6 +1,7 @@ * Table of Contents :TOC: - [[#misc][Misc]] - [[#theme][Theme]] + - [[#dark-theme-toggle][Dark theme toggle]] - [[#font][Font]] - [[#line-numbers][Line numbers]] - [[#battery-indicator][Battery indicator]] @@ -38,6 +39,37 @@ https://github.com/hlissner/emacs-doom-themes (setq doom-theme 'doom-solarized-light) #+END_SRC +** Dark theme toggle + +I've come to prefer using a light theme during the day, and a dark theme at +night. Using a dark theme with daylight leads to cranking up the screen +brightness, which hurts my eyes more than using the light theme. + +Set my light and dark themes: + +#+BEGIN_SRC emacs-lisp +(setq my/light-theme doom-theme + my/dark-theme 'doom-one) +#+END_SRC + +Function to toggle between the two easily: + +#+BEGIN_SRC emacs-lisp +(defun my/toggle-dark-theme () + (interactive) + (if (eq my/dark-theme doom-theme) + (load-theme my/light-theme t) + (load-theme my/dark-theme t))) +#+END_SRC + +Bind this to =SPC t d=: + +#+BEGIN_SRC emacs-lisp +(map! :leader + (:prefix-map ("t" . "toggle") + :desc "Dark theme" "d" #'my/toggle-dark-theme)) +#+END_SRC + ** Font Doom exposes five (optional) variables for controlling fonts in Doom. Here are