aboutsummaryrefslogtreecommitdiffstats
path: root/oni-circe.el
diff options
context:
space:
mode:
Diffstat (limited to 'oni-circe.el')
-rw-r--r--oni-circe.el91
1 files changed, 46 insertions, 45 deletions
diff --git a/oni-circe.el b/oni-circe.el
index d3cfbf5..0a674de 100644
--- a/oni-circe.el
+++ b/oni-circe.el
@@ -95,51 +95,52 @@ which may be encrypted."
(enable-circe-color-nicks)
(enable-circe-serenity)
-;; (require 'mowedline)
-
-;; (defun mowedline-colorize-mode-line-spec (s)
-;; (cond
-;; ((stringp s) (string-trim s))
-;; ((eq ':propertize (car s))
-;; (let ((s (cadr s))
-;; (face (plist-get (cddr s) 'face)))
-;; (if face
-;; `(color ,(face-foreground face)
-;; ,(substring-no-properties s))
-;; s)))
-;; (t "")))
-
-;; (setq mowedline-update-function 'mowedline-update/dbus)
-
-;; (defvar jjf-tracking-buffers '())
-;; (defvar jjf-external-tracking-timer nil)
-;; (defun jjf-external-tracking ()
-;; (setq jjf-external-tracking-timer nil)
-;; (mowedline-update
-;; 'irc
-;; (if (stringp jjf-tracking-buffers)
-;; (mowedline-colorize jjf-tracking-buffers t)
-;; (format "%S" (mapcar #'mowedline-colorize-mode-line-spec
-;; jjf-tracking-buffers)))))
-
-;; (defun oni:clear-irc-mowedline-widget ()
-;; (mowedline-clear 'irc))
-
-;; (defun jjf-external-tracking-advice (orig-fun &rest args)
-;; "Update my external status bar when tracking computes a new
-;; status line, and 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 jjf-tracking-buffers (apply orig-fun args))
-;; (when jjf-external-tracking-timer
-;; (cancel-timer jjf-external-tracking-timer))
-;; (setq jjf-external-tracking-timer
-;; (run-at-time 0.2 nil 'jjf-external-tracking))
-;; nil)
-
-;;(advice-add 'tracking-status :around #'jjf-external-tracking-advice)
-;;(add-hook 'kill-emacs-hook 'oni:clear-irc-mowedline-widget)
+;;; Polybar
+;; This was originally written by retroj in his own configuration and shared
+;; 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)
+
+(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-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)
+
+(advice-add 'tracking-status :around #'oni-circe-polybar-tracking)
(add-hook 'circe-channel-mode-hook 'olivetti-mode)