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
140 stars 34 forks source link

[Question] how to make it work with emacsclient #32

Closed idr4n closed 1 year ago

idr4n commented 1 year ago

Hi and thanks for a nice package!

I'm using Emacs 30 in macOS and the package works perfectly when starting Emacs normally, not as an emacsclient. However, when trying to run emacs as a server, I was getting an error due to this package and the server wouldn't start properly.

I'm relatively new to Emacs and found out that even things like fonts and shell paths don't initialize properly when running as a server, so I found a solution that I applied to this package, which at the moment is actually working for me, but I would like to confirm that this is a good solution or whether there is a better one:

(defun id/server-auto-dark (frame)
  (use-package auto-dark
    :config (auto-dark-mode t)
    :diminish auto-dark-mode
    :custom
    ;; (auto-dark-dark-theme 'doom-vibrant)
    (auto-dark-dark-theme 'kaolin-bubblegum)
    (auto-dark-light-theme 'modus-operandi)
    (set-cursor-color "#dc322f"))
    (remove-hook 'after-make-frame-functions #'id/server-auto-dark)
  )
(add-hook 'after-make-frame-functions #'id/server-auto-dark)

Thanks in advance!

LionyxML commented 1 year ago

Thanks @idr4n !

I am sorry it took so long to reply.

I would do exactly what you've made (btw, I just tested with Emacs 30 and it still works).

There's a hook that you can use whenever a client is loaded, but auto-dark-emacs cries if there's no windows loaded when you call it, so yeah, asking for frames is the right call.

Just a side note, for terminal instances you'd still have to manually load auto-dark-mode, but most users don't want terminal changing with system decoration :)