Okay! here to report back!
With the great help of BigEatie, I have completed this project. The following changes make this happen.
First I have added to ~/.config/polybar/config :
modules-left = exwm-workspace mode-line
and
[module/mode-line]
type = custom/ipc
hook-0 = emacsclient -e “(mode-line-string)” | sed -e ‘s/^"//’ -e ‘s/"$//’
initial = 1
format-underline = ${colors.underline-1}
format-padding = 1
[module/exwm-workspace]
type = custom/ipc
hook-0 = emacsclient -e “exwm-workspace-current-index” | sed -e ‘s/^"//’ -e ‘s/"$//’
initial = 1
format-underline = ${colors.underline-1}
format-padding = 1
As for my emacs config:
(defun efs/send-polybar-exwm-workspace ()
(efs/send-polybar-hook “exwm-workspace” 1))
;; the code inside the function below is courtesy of BigEatie.
(defun mode-line-string ()
(let* ((mode-line-string (format-mode-line mode-line-format))
(start 0)
(end (length mode-line-string)))
(set-text-properties start end nil mode-line-string)
mode-line-string))
(defun efs/send-polybar-mode-line ()
(efs/send-polybar-hook “mode-line” 1))
;; setting the below to ‘.01 .01’ is much more responsive, but significantly kicks
;; up my computers resources.
(run-with-timer .1 .1 (lambda () (efs/send-polybar-mode-line)))
All that is left is to:
(use-package hide-mode-line
:ensure t
:config
(global-hide-mode-line-mode t))
And that does it! mode-line-format is now in polybar and I am free of multiple mode lines for each window buffer.
Thanks again to BigEatie, and hopefully others use this and find ways to optimize.
Cheers!
edit: One change that could be made is using the post-command-hook instead of a timer to relieve the machine of constantly updating the mode-line-string function.