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