Commit 505cd1ebb9f9

Vincent Demeester <vincent@sbr.pm>
2020-01-30 11:09:38
setup-style.el: auto theme switcher ๐Ÿ’ญ
Switch the theme depending on the time of the day ๐Ÿ™ƒ Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent f13266a
Changed files (1)
lisp/setup-style.el
@@ -188,6 +188,26 @@
 (use-package hide-mode-line-mode
   :commands hide-mode-line-mode)
 
+(defun set-light-theme ()
+  "Set the light theme with some customization if needed."
+  (interactive)
+  (load-theme 'doom-one-light t))
+
+(defun set-dark-theme ()
+  "Set the dark theme with some customization if needed."
+  (interactive)
+  (load-theme 'doom-one t))
+
+(defun theme-switcher ()
+  (interactive)
+  (let ((current-hour (string-to-number (format-time-string "%H"))))
+    (if (and (> current-hour 6) (< current-hour 20))
+        (set-light-theme)
+      (set-dark-theme))))
+
+;; Run at every 3600 seconds, after 0s delay
+(run-with-timer 0 3600 'theme-switcher)
+
 (provide 'setup-style)
 
 ;; Local Variables: