Help making a dynamic titlebar

[email protected] Thu, 09 Apr 2015 20:39:10 +0100
Newsgroups gmane.comp.window-managers.sawfish
Message-ID <[email protected]>
I need some help making a dynamic window-title. This is meant to work by 
joining the current date and time to the window-title, and updating 
every 5 seconds on a rep timer. To test this out you can just paste is 
straight into a config. I'm not a programmer, so realise the code is 
probably crap, but I'm trying to learn. The problem I'm having is 
window-titles with special characters breaking the code, e.g., the play 
icon when playing Youtube videos in Firefox. Such symbols cause the 
title to grow bigger and bigger with garbled text each update of the 
timer.

I'm not sure if the error is in the logic of my code (perhaps I'm using 
the timers wrong) or whether one of the functions needs patching to deal 
with the special characters.

(require 'rep.io.timers)
(require 'rep.util.utf8)

(define titlebar-status-timer
   (make-timer (lambda ()
                 (titlebar-status-update)) 2))

(defun titlebar-status-update ()
   "Update the titlebar status"
   (set-timer titlebar-status-timer 5)
   (map-windows (lambda (x)
                  (let ((status-string (concat "[" (current-time-string 
nil "%d\/%m %H:%M") "] ")))
                    (if (string-match "^[[]...........[]] " (window-name 
x))
                        (let ((title-without-status (utf8-substring 
(window-name x) 14)))
                          (rename-window x (concat status-string 
title-without-status)))
                      (rename-window x (concat status-string (window-name 
x))))
                      ))))

Thanks for any help.

-- 
Sawfish ML