diff options
author | Miguel Ángel Moreno <mail@migalmoreno.com> | 2023-02-17 12:34:52 +0100 |
---|---|---|
committer | Miguel Ángel Moreno <mail@migalmoreno.com> | 2023-02-17 12:34:52 +0100 |
commit | 8d02507dbd3824497d7c7b87ff9d5010ade7b8fa (patch) | |
tree | 47ab3f1925960e708c1211fcb56a0986265103fa | |
parent | d6371d5d896faa3227e62e0a0435ffc319e8fabe (diff) |
fix: Apply styles for modes and timers after buffer is loaded
-rw-r--r-- | tailor.lisp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tailor.lisp b/tailor.lisp index 9f5e0d7..75bbb0b 100644 --- a/tailor.lisp +++ b/tailor.lisp @@ -149,10 +149,11 @@ Optionally, retrieve the original style of OBJ via STYLE-SLOT." (defmethod load-style (style (nyxt-mode nyxt:mode)) (flet ((style-mode (mode) - (setf (slot-value nyxt-mode 'nyxt:style) - (compute-current-style style nyxt-mode)))) - (style-mode nyxt-mode) - (hooks:add-hook (nyxt:enable-mode-hook (nyxt:buffer nyxt-mode)) + (setf (slot-value mode 'nyxt:style) + (compute-current-style style mode)))) + (hooks:once-on (nyxt:buffer-loaded-hook (buffer nyxt-mode)) (_) + (style-mode nyxt-mode)) + (hooks:add-hook (nyxt:enable-mode-hook (buffer nyxt-mode)) (make-instance 'hooks:handler :fn #'style-mode :name 'style-mode)))) @@ -248,9 +249,9 @@ If DARK, find the first dark `user-theme'." (local-time:timestamp-to-universal threshold) :absolute-p t :repeat-interval 86400)))) - (set-timer *light-theme-timer* light-theme light-theme-threshold) - (sleep 0.01) - (set-timer *dark-theme-timer* dark-theme dark-theme-threshold)))))) + (hooks:once-on (nyxt:buffer-loaded-hook (buffer mode)) (_) + (set-timer *light-theme-timer* light-theme light-theme-threshold) + (set-timer *dark-theme-timer* dark-theme dark-theme-threshold))))))) (defmethod nyxt:disable ((mode tailor-mode) &key) (hooks:remove-hook (nyxt:buffer-before-make-hook *browser*) 'style-web-buffer) |