From fba678fa1c21d35e0972c4036c0e209e155d07b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Sun, 27 Oct 2024 16:41:36 -0700 Subject: emacs: mv themes.el to package rul-themes --- .emacs.d/init.el | 2 +- .emacs.d/rul-init.d/themes.el | 48 ------------------------------ .emacs.d/rul-lisp/packages/rul-themes.el | 50 ++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 49 deletions(-) delete mode 100644 .emacs.d/rul-init.d/themes.el create mode 100644 .emacs.d/rul-lisp/packages/rul-themes.el (limited to '.emacs.d') diff --git a/.emacs.d/init.el b/.emacs.d/init.el index c708afb..e245cf3 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -70,6 +70,7 @@ (dolist (path '("~/.emacs.d/rul-lisp/config" "~/.emacs.d/rul-lisp/packages")) (add-to-list 'load-path path)) +(require 'rul-themes) (require 'rul-completion) (require 'rul-fm) (require 'rul-prog) @@ -81,7 +82,6 @@ (require 'rul-write) ;; Init parts (will be deprecated in favor of packages) -(load-file "~/.emacs.d/rul-init.d/themes.el") (load-file "~/.emacs.d/rul-init.d/auto-fill.el") (load-file "~/.emacs.d/rul-init.d/flycheck.el") (load-file "~/.emacs.d/rul-init.d/flyspell.el") diff --git a/.emacs.d/rul-init.d/themes.el b/.emacs.d/rul-init.d/themes.el deleted file mode 100644 index 468cd28..0000000 --- a/.emacs.d/rul-init.d/themes.el +++ /dev/null @@ -1,48 +0,0 @@ -(use-package modus-themes :ensure t) -(use-package ef-themes :ensure t) - -(setq - modus-themes-mode-line '(accented borderless padded) - modus-themes-region '(bg-only) - modus-themes-bold-constructs t - modus-themes-italic-constructs t - modus-themes-paren-match '(bold intense) - modus-themes-headings (quote ((1 . (rainbow variable-pitch 1.3)) - (2 . (rainbow 1.1)) - (t . (rainbow)))) - modus-themes-org-blocks 'tinted - ) - -(use-package dbus) -(defun mf/set-theme-from-dbus-value (value) - "Set the appropiate theme according to the color-scheme setting value." - (message "value is %s" value) - (if (equal value '1) - (progn (message "Switch to dark theme") - (modus-themes-select 'modus-vivendi)) - (progn (message "Switch to light theme") - (modus-themes-select 'modus-operandi)))) - -(defun mf/color-scheme-changed (path var value) - "DBus handler to detect when the color-scheme has changed." - (when (and (string-equal path "org.freedesktop.appearance") - (string-equal var "color-scheme")) - (mf/set-theme-from-dbus-value (car value)) - )) - -;; Register for future changes -(dbus-register-signal - :session "org.freedesktop.portal.Desktop" - "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" - "SettingChanged" - #'mf/color-scheme-changed) - -;; Request the current color-scheme -(dbus-call-method-asynchronously - :session "org.freedesktop.portal.Desktop" - "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" - "Read" - (lambda (value) (mf/set-theme-from-dbus-value (caar value))) - "org.freedesktop.appearance" - "color-scheme" - ) diff --git a/.emacs.d/rul-lisp/packages/rul-themes.el b/.emacs.d/rul-lisp/packages/rul-themes.el new file mode 100644 index 0000000..f3df8a8 --- /dev/null +++ b/.emacs.d/rul-lisp/packages/rul-themes.el @@ -0,0 +1,50 @@ +(use-package modus-themes :ensure t) +(use-package ef-themes :ensure t) + +(setq + modus-themes-mode-line '(accented borderless padded) + modus-themes-region '(bg-only) + modus-themes-bold-constructs t + modus-themes-italic-constructs t + modus-themes-paren-match '(bold intense) + modus-themes-headings (quote ((1 . (rainbow variable-pitch 1.3)) + (2 . (rainbow 1.1)) + (t . (rainbow)))) + modus-themes-org-blocks 'tinted) + +(use-package dbus) +(defun mf/set-theme-from-dbus-value (value) + "Set the appropiate theme according to the color-scheme setting value." + (message "value is %s" value) + (if (equal value '1) + (progn (message "Switch to dark theme") + (modus-themes-select 'modus-vivendi)) + (progn (message "Switch to light theme") + (modus-themes-select 'modus-operandi)))) + +(defun mf/color-scheme-changed (path var value) + "DBus handler to detect when the color-scheme has changed." + (when (and (string-equal path "org.freedesktop.appearance") + (string-equal var "color-scheme")) + (mf/set-theme-from-dbus-value (car value)) + )) + +;; Register for future changes +(dbus-register-signal + :session "org.freedesktop.portal.Desktop" + "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" + "SettingChanged" + #'mf/color-scheme-changed) + +;; Request the current color-scheme +(dbus-call-method-asynchronously + :session "org.freedesktop.portal.Desktop" + "/org/freedesktop/portal/desktop" "org.freedesktop.portal.Settings" + "Read" + (lambda (value) (mf/set-theme-from-dbus-value (caar value))) + "org.freedesktop.appearance" + "color-scheme" + ) + + +(provide 'rul-themes) -- cgit v1.2.3