Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration with macOS system theme preference? #22

Open
rollcat opened this issue Nov 29, 2019 · 2 comments
Open

Integration with macOS system theme preference? #22

rollcat opened this issue Nov 29, 2019 · 2 comments
Assignees

Comments

@rollcat
Copy link

rollcat commented Nov 29, 2019

I'm looking for a way to synchronise the Emacs theme with light/dark/auto mode on macOS. I understand the current method is completely cross-platform, but it would be great to integrate with specific platforms' capabilities.

@guidoschmidt
Copy link
Owner

@rollcat I just discovered, that emacs-plus is implementing that feature. Might be worth checking it out. I could imagine to integrate it into circadian.el as well

@guidoschmidt guidoschmidt self-assigned this Jan 9, 2021
@rollcat
Copy link
Author

rollcat commented Jan 9, 2021

Nice find!

In the meantime, I've been able to hack this together:

(setq system-is-mac (equal "darwin" (symbol-name system-type)))

(defun get-appearance-preferences ()
  (if system-is-mac
      (do-applescript "tell application \"System Events\"
  tell appearance preferences
    if (dark mode) then
      return \"dark\"
    else
      return \"light\"
    end if
  end tell
end tell")
    "dark"))
(defun update-theme ()
  (let ((ap (get-appearance-preferences)))
    (cond
        ((equal ap "dark")  (load-theme preferred-dark-theme))
        ((equal ap "light") (load-theme preferred-light-theme))
        (t nil))))

Of course this does not respond to system theme change events; however I've turned off automatic switching, since in the winter I usually want the dark theme enabled earlier in the day than what the system thinks is appropriate (which brings us full circle to the problem that Circadian is addressing...) And instead I have an Automator shortcut which toggles system appearance, followed by running emacsclient -e '(update-theme)'.

I'm probably gonna try emacs-plus though. Thanks :)

@guidoschmidt guidoschmidt added this to the 0.5.0 milestone Apr 22, 2024
@guidoschmidt guidoschmidt removed this from the 1.0.0 milestone Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants