[Sawfish] Help making a dynamic titlebar

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


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


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/