Add nyan-mode

This commit is contained in:
eriedaberrie 2023-03-30 23:04:35 -07:00
parent 3f72abec2e
commit 518423333b

30
init.el
View file

@ -723,6 +723,11 @@
(term-exec . with-editor-export-editor) (term-exec . with-editor-export-editor)
(vterm-mode . with-editor-export-editor)) (vterm-mode . with-editor-export-editor))
(use-package nyan-mode
:custom
(nyan-animate-nyancat t)
(nyan-wavy-trail t))
(use-package smtpmail (use-package smtpmail
:ensure nil :ensure nil
:custom :custom
@ -920,20 +925,27 @@
(with-current-buffer "*scratch*" (with-current-buffer "*scratch*"
(cd "~/"))) (cd "~/")))
(defvar my-bat-previous-status nil (defvar my-ac-previous-status t
"Whether battery was in use on last check.") "Whether battery was not in use on last check.")
(require 'battery) (require 'battery)
(defun my-bat-check () (defun my-bat-check ()
"Check if battery status has changed. "Check if battery status has changed.
Used to toggle `goggles-pulse' and `pixel-scroll-precision-mode'." Used to toggle `goggles-pulse', `pixel-scroll-precision-mode', and `nyan-mode'."
(let ((bat-status (string-equal (cdr (assq ?L (funcall battery-status-function))) (let ((ac-status (not (string=
"BAT"))) (cdr (assq ?L (funcall battery-status-function)))
(unless (eq bat-status my-bat-previous-status) "BAT"))))
(setq my-bat-previous-status bat-status) (unless (eq ac-status my-ac-previous-status)
(setq my-ac-previous-status ac-status)
(when (boundp 'goggles-pulse) (when (boundp 'goggles-pulse)
(setq goggles-pulse (not bat-status))) (setq goggles-pulse ac-status))
(pixel-scroll-precision-mode (if bat-status 0 1))))) (when nyan-mode
(if ac-status
(nyan-start-animation)
(nyan-stop-animation)))
(setq nyan-animate-nyancat ac-status
nyan-wavy-trail ac-status)
(pixel-scroll-precision-mode (if ac-status 1 0)))))
(when battery-status-function (when battery-status-function
(run-with-timer 0 30 #'my-bat-check)) (run-with-timer 0 30 #'my-bat-check))