Skip to content

Commit

Permalink
Correction for timer performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Uswald committed Jan 26, 2022
1 parent 711cd74 commit 25d4111
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ghb.el
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
;; along with this program. If not, see <http://www.gnu.org/licenses/>.

;;; Commentary:
;;

;; This package propose to insert a frame header bar with :
;; - project name;
;; - date and time;
;; - battery information.
;;

;;; Code:

(require 'all-the-icons)
Expand Down Expand Up @@ -198,15 +198,15 @@ command starts, by installing a pre-command hook."
(when (null (ghb-get ghb-timer frame))
;; Set up the timer first, so that if this signals an error,
;; ghb is not added to pre-command-hook.
(ghb--start-timer frame)))
;; (add-hook 'pre-command-hook (lambda () (ghb-end frame)))))
(ghb--start-timer frame)
(add-hook 'pre-command-hook `(lambda () (ghb-end ,frame)))))

(defun ghb-end (&optional frame)
"Stop header bar updating.
This is installed as a pre-command hook by `ghb-start'.
When run, it cancels the timer `ghb-timer' and removes
itself as a pre-command hook."
;; (remove-hook 'pre-command-hook (lambda () (ghb-end frame)))
(remove-hook 'pre-command-hook `(lambda () (ghb-end ,frame)))
(let ((timer (ghb-get ghb-timer frame)))
(when timer
(cancel-timer timer)
Expand Down Expand Up @@ -367,5 +367,7 @@ itself as a pre-command hook."
(advice-add 'desktop-save :before 'ghb-close)
(advice-add 'desktop-save :after 'ghb-open)

(setq ghb-time-idle-delay 5.0)

(provide 'ghb)
;;; ghb.el ends here

0 comments on commit 25d4111

Please sign in to comment.