[Sawfish] Help making a dynamic titlebar |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/sawfish Archives
]
- To: sawfish@xxxxxxxxxxxxxxxxxxx
- Subject: [Sawfish] Help making a dynamic titlebar
- From: hoplaahei@xxxxxxxxxxxxxxx
- Date: Thu, 09 Apr 2015 20:39:10 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=openmailbox.org; h=user-agent:message-id:subject:subject:from:from:date:date :content-transfer-encoding:content-type:content-type :mime-version:received:received; s=openmailbox; t=1428608350; bh=qedDxc+7wy+E15XuEWEydn2WRSNC24U3MxlNLZIVfZo=; b=trylfExf9b7n pGphd9C+RW2+cldFULcJlRzpIwbic82kYrsFFBFlWzPNmaMvbJ/983LA4HTmE3US Bep/ZaTw+/v1ukuVq5EW4v+LYptXUi77ffPwA5kEB7OiihzLaUhU1WINb3U3xRFa iocV9ZO7geUuns+klaWTPk2YiGdTZJg=
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