LionyxML / auto-dark-emacs

Auto-Dark-Emacs is an auto changer between 2 themes, dark/light, following MacOS, Linux or Windows Dark Mode settings
GNU General Public License v2.0
158 stars 35 forks source link

The package does not check system's theme on startup #63

Closed tareefdev closed 2 months ago

tareefdev commented 2 months ago

When starting Emacs, the package does not check the system's current theme; thus, Emacs fails to use one of its default themes. I have to toggle the dark mode on/off on my system so the package detects the system's theme and applies the corresponding theme. However, I don't know if this is the expected behavior.

Info: GNU Emacs 29.4 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0) ArchLinux with Gonme 46

LionyxML commented 2 months ago

Hello there @tareefdev!

Would you mind checking if your Messages buffer or emacs --debug-init gives any tips, warnings or errors regarding auto-dark?

I remember having such a problem back in the day, but I've just tested it here and it seems to be working o Linux(Debian) and macOS.

So, debugging questions: are you using doom, spacemacs or some distro? How did you setup auto-dark? Via use-package?

tareefdev commented 2 months ago

I installed emacs from the official repo; however, I forgot to mention that I use the PGTK branch on Wayland session. I don't use any distro just my custom configs.

The content of Messages buffer seems fine:

Loading /home/tareef/.emacs.d/elpa/vertico/extensions/vertico-autoloads.el (source)...done
Loading /home/tareef/.emacs.d/settings.el (source)...
Clearing removed files...done
Processing modified files...done
[yas] Prepared just-in-time loading of snippets successfully.
Loading corfu-history (native compiled elisp)...done
Prettier restart complete.
Loading /home/tareef/.emacs.d/settings.el (source)...done
Loaded /home/tareef/.emacs.d/settings.el
Turning on magit-auto-revert-mode...done
For information about GNU Emacs and the GNU system, type C-h C-a.
Emacs loaded in 7.13 seconds with 74 garbage collections.
Mark set
C-x n C-x h is undefined

Here is the relative config:

(use-package auto-dark
  :config (auto-dark-mode t)
  (setq auto-dark-light-theme 'doom-gruvbox-light)
  (setq auto-dark-dark-theme 'doom-gruvbox))
tareefdev commented 2 months ago

After updating to Gnome 47, the plugin does not work at all. emacs --debug-init shows nothing helpful. Thanks for your help.

LionyxML commented 2 months ago

Right! @tareefdev, would you please try setting up auto-dark this way?

(use-package auto-dark
  :ensure t
  :custom
  (custom-safe-themes t) 
  (auto-dark-themes '((doom-gruvbox-light) (doom-gruvbox)))
  :init (auto-dark-mode))
tareefdev commented 2 months ago

The provided snippet solved the issue. Now, auto-dark checks the system's theme on startup and works as expected again.

This issue made me read a bit from the use-package manual, so the :config keyword executes after the package is loaded, so on-loading the auto-dark-light-theme and auto-dark-dark-theme variables are not set correctly yet, while :custom is used to set the variables before the package's functions are run?

Also, I read to prefer autoloading keywords instead of :init and modified your snippet a bit:

  (use-package auto-dark
    :hook (after-init . auto-dark-mode)
    :custom (auto-dark-themes '((doom-gruvbox)
                (doom-gruvbox-light))))

Thanks for your help!

LionyxML commented 2 months ago

Nice! I am happy it worked for you @tareefdev!

Not an expert here, but your assessment regarding custom and config seems right :smile: