Emacs Theme Switcher

Monday, September 2, 2024

Table of Contents

theme-switcher.gif

Figure 1: demo

I like to switch my emacs theme several times a day. I do this based on the time of day, brightness of the room I'm currently in, and my mood. So I made a little emacs package to make it more comfy to do so.

It provides 2 features:

Installation/Setup

Clone the repository in your preferred destination.

cd ~/path/to
git clone https://github.com/Duncan-Britt/theme-switcher.git

Add the following to your config, specifying the path to the cloned repository, as well as your preferred light and dark themes.

(use-package theme-switcher
  :load-path "~/path/to/theme-switcher/"                            ; (path)
  :after org
  :config
  (setq *theme-switcher-themes-light* '("ef-day" "leuven"))         ; (light)
  (setq *theme-switcher-themes-dark* '("ef-elea-dark" "ef-cherie")) ; (dark)
  :bind
  ("C-t" . theme-switcher-choose-theme)
  (:map org-mode-map
        ("C-c C-x C-v" . ts-toggle-inline-images)))

To find your available themes, you can use M-x customize-themes.

Usage/Keybindings

Switching Themes

Enter C-t to choose a theme in the mini buffer.

Light and dark mode images

To use this functionality, you first need to make your light and dark mode versions of your image and name them name.extension and name-dark.extension, respectively. For example, I could have files directed-graph.png and directed-graph-dark.png. They must be in the same directory.

Then, in org mode, link to the file like so: [[path/to/directed-graph.png]]. When you display inline images, if you are in dark mode, or switch to dark mode, directed-graph-dark.png will be displayed instead of directed-graph.png.

Date: 2024-09-02 Mon 00:00