Subject: Re: bug#17349: 24.3.50; display-battery-mode stops updating after closing and reopening lid

From: Peter Münster <[email-masked]>
Date: Thu, 22 Jan 2015 10:43:31 +0100

On Fri, Jun 27 2014, Peter Münster wrote:

> Do you think, that this will be fixed soon? If not, I'll install a
> workaround with crond and emacsclient.

Works quite nicely since some months:

--8<---------------cut here---------------start------------->8---
(defun pm/start-timer (sym func &rest args)
  (cl-pushnew (list sym func args) pm/timer-list)
  (apply func args))

(defun pm/gnus-demon-add-handler (sym period idle)
  (pm/start-timer sym 'gnus-demon-add-handler sym period idle))

(defun pm/timer-running-p (func)
  (dolist (timer (append timer-list timer-idle-list))
    (if (or (eq (timer--function timer) func)
            (and (eq (timer--function timer) 'gnus-demon-run-callback)
                 (eq (car (timer--args timer)) func)))
          (return (not (timer--triggered timer))))))

(defun pm/check-timers ()
  (dolist (e pm/timer-list)
    (lexical-let ((entry e) (timer (first e)))
      (unless (pm/timer-running-p timer)
        (if (display-graphic-p)
            (notifications-notify
             :title "Timer is dead!"
             :body  (symbol-name timer)
             :timeout (* 55 60 1000)
             :actions '("delete" "delete entry" "restart" "restart timer")
             :on-action (lambda (id key) (pm/timer-action entry key)))
          (message "Timer is dead: %s" timer))))))
--8<---------------cut here---------------end--------------->8---

And once per hour, crond executes  "emacsclient -e '(pm/check-timers)'"

When a timer is dead, I just need to restart it with a mouse-click.

-- 
           Peter