1
0
Fork 0

[oni-circe] Disable sending tracking to polybar

I'm not using polybar anymore.
This commit is contained in:
Tom Willemse 2023-07-26 00:35:27 -07:00
parent 3ec56e9641
commit e497aeccae

View file

@ -4,7 +4,7 @@
;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0717.113326
;; Version: 2023.0725.143552
;; Package-Requires: (circe oni-lui circe-serenity olivetti)
;; This program is free software; you can redistribute it and/or modify
@ -108,54 +108,55 @@ which may be encrypted."
;; with me from when I was using mowedline. I've adapted the code to work for
;; polybar instead and renamed all of the functions.
(defvar oni-circe-tracking-buffers nil)
(defvar oni-circe-tracking-timer nil)
;; (defvar oni-circe-tracking-buffers nil)
;; (defvar oni-circe-tracking-timer nil)
(defun oni-circe-colorize (s)
"Turn any color description of S into one that Polybar understands."
(cond
((stringp s) (string-trim s))
((eq ':propertize (car s))
(let ((s (cadr s))
(face (plist-get (cddr s) 'face)))
(if face
(format "%%{F%s}%s%%{F-}"
(face-foreground face)
(substring-no-properties s))
s)))
(t "")))
;; (defun oni-circe-colorize (s)
;; "Turn any color description of S into one that Polybar understands."
;; (cond
;; ((stringp s) (string-trim s))
;; ((eq ':propertize (car s))
;; (let ((s (cadr s))
;; (face (plist-get (cddr s) 'face)))
;; (if face
;; (format "%%{F%s}%s%%{F-}"
;; (face-foreground face)
;; (substring-no-properties s))
;; s)))
;; (t "")))
(defun oni-circe-update-polybar ()
"Send a command to Polybar to update my Circe widget."
(setq oni-circe-tracking-timer nil)
(shell-command (format "polybar-msg action circe send %s"
(shell-quote-argument
(if (stringp oni-circe-tracking-buffers)
(oni-circe-colorize oni-circe-tracking-buffers)
(mapconcat #'oni-circe-colorize oni-circe-tracking-buffers))))))
;; (defun oni-circe-update-polybar ()
;; "Send a command to Polybar to update my Circe widget."
;; (setq oni-circe-tracking-timer nil)
;; (shell-command (format "polybar-msg action circe send %s"
;; (shell-quote-argument
;; (if (stringp oni-circe-tracking-buffers)
;; (oni-circe-colorize oni-circe-tracking-buffers)
;; (mapconcat #'oni-circe-colorize oni-circe-tracking-buffers))))))
(defun oni-circe-tracking-clear ()
(shell-command "polybar-msg action circe send \"\"")) ;
;; (defun oni-circe-tracking-clear ()
;; (shell-command "polybar-msg action circe send \"\"")) ;
(defun oni-circe-polybar-tracking (orig-fun &rest args)
"Update my external status bar when tracking computes a new status line.
;; (defun oni-circe-polybar-tracking (orig-fun &rest args)
;; "Update my external status bar when tracking computes a new status line.
Also suppress tracking in the mode-line. Since tracking-status
may be called many times in quick succession, for example on a
make-frame-visible event, we use a short timer to only call the
updater once within a minimum duration."
(setq oni-circe-tracking-buffers (apply orig-fun args))
(when oni-circe-tracking-timer
(cancel-timer oni-circe-tracking-timer))
(setq oni-circe-tracking-timer
(run-at-time 0.2 nil #'oni-circe-update-polybar))
nil)
;; Also suppress tracking in the mode-line. Since tracking-status
;; may be called many times in quick succession, for example on a
;; make-frame-visible event, we use a short timer to only call the
;; updater once within a minimum duration."
;; (setq oni-circe-tracking-buffers (apply orig-fun args))
;; (when oni-circe-tracking-timer
;; (cancel-timer oni-circe-tracking-timer))
;; (setq oni-circe-tracking-timer
;; (run-at-time 0.2 nil #'oni-circe-update-polybar))
;; nil)
(advice-add 'tracking-status :around #'oni-circe-polybar-tracking)
;; (advice-add 'tracking-status :around #'oni-circe-polybar-tracking)
;; (advice-remove 'tracking-status #'oni-circe-polybar-tracking)
(add-hook 'circe-channel-mode-hook 'olivetti-mode)
(add-hook 'kill-emacs-hook 'oni-circe-tracking-clear)
;; (add-hook 'kill-emacs-hook 'oni-circe-tracking-clear)
(provide 'oni-circe)
;;; oni-circe.el ends here