Skip to content

Instantly share code, notes, and snippets.

@corpix
Last active February 18, 2018 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corpix/ca3b91b9b17bbbbb9470fd0fc95783b6 to your computer and use it in GitHub Desktop.
Save corpix/ca3b91b9b17bbbbb9470fd0fc95783b6 to your computer and use it in GitHub Desktop.
;; Disable flycheck when on battery
(defun toggle-flycheck ()
(when (fboundp 'battery-status-function)
(let
((battery-status (battery-format "%L" (funcall battery-status-function))))
(cond
((string-match-p "N/A" battery-status) (global-flycheck-mode +1))
((string-match-p "AC" battery-status) (global-flycheck-mode +1))
(t (global-flycheck-mode -1))))))
(run-with-idle-timer 5 1 'toggle-flycheck)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment