Skip to content

Latest commit

 

History

History
185 lines (141 loc) · 5.9 KB

darkman.org

File metadata and controls

185 lines (141 loc) · 5.9 KB

Darkman for Emacs

@@latex:\clearpage@@

This is the manual for darkman.el version {{{version}}}.

GNU Free Documentation License

Copyright (C) 2023 {{{author}}}.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

Installation

Usage

In your init.el file, define which theme is associated with which mode. By default, modus-themes will be used, but we’ll choose the tango variants in this example.

(setq darkman-themes '(:light tango :dark tango-dark))

You can also use M-x customize-group darkman RET to customize the variable.

darkman can listen for any signals to change the theme without requiring you to manually create any scripts. You can enable this behavior by enabling the minor mode:

(darkman-mode)

You should not call load-theme in your configuration as darkman-mode when enabled will do that for you, even on startup.

Other functions

M-x darkman-toggle will toggle the mode of the Darkman service from within Emacs.

Additionally, you can use the darkman-get and darkman-set functions to manually get and set the mode of the service respectively.

Tips

Working alongside the built-in safety features

load-theme is part of the custom library and it comes with certain security features that you may regard as inconvenient, but they’re absolutely necessary to preserve the security of your system. We have decided to work hand in hand with these pre-existing safety mechanisms in lieu of implementing our own.

Problems may arise [fn:1] if this package is loaded in a server setting and too early during the initialization phase, i.e. before custom-file, you can prevent this from happening by activating the mode only when the session has been fully initialized:

(when (daemonp)
  (add-hook 'server-after-make-frame-hook #'darkman-mode)
  (advice-add 'darkman-mode
	      :after
              (lambda ()
                (remove-hook 'server-after-make-frame-hook
			     #'darkman-mode))))

Working alongside the third-party spacious-padding package

spacious-padding significantly improves the aesthetics of our beloved Emacs by padding the windows and mode line. I’ve personally encountered an issue that made spacious-padding behave incorrectly when (1) used in conjuction with darkman-mode and (2) when Emacs is started as a daemon, resulting in window/mode line borders being assigned the wrong color.

I found, through trial and error, that simply delaying the activation of spacious-padding when started in daemon mode until the first frame has appeared solved the problem.

(if (daemonp)
    (add-hook 'server-after-make-frame-hook #'spacious-padding-mode)
  (spacious-padding-mode))

Disabling existing themes

Emacs does not by default disable the current theme when another one is loaded, and while this behavior might seem counter-intuitive, we can always advise darkman-set-theme (and by extension darkman-toggle), or even load-theme if you prefer, to disable any existing themes first.

(defun disable-existing-themes ()
  "Disable any activated themes before loading a new one."
  (mapc #'disable-theme custom-enabled-themes))

(advice-add #'darkman-set-theme :before #'disable-existing-themes)

Debugging

Is D-Bus running?

Use your service manager to verify whether the darkman service is running, here’s an example using systemd:

systemctl status dbus
dbus.service - D-Bus System Message Bus
   Loaded: loaded
   Active: active (running)

Is Darkman running?

Use your service manager to verify whether the darkman service is running, here’s an example using systemd:

systemctl status --user darkman
darkman.service - Framework for dark-mode and light-mode transitions.
   Loaded: loaded
   Active: active (running)

Is Emacs built with D-Bus support?

Usually it is, unless you’re building from source, in which case you can verify whether or not Emacs was built with D-Bus support using C-h v system-configuration-features RET which should list DBUS.

Footnotes

[fn:1] This is known to happen in Doom Emacs.