Update dzen code to handle weirder cases better
This commit is contained in:
parent
e124f8b7f4
commit
86741f9a10
1 changed files with 36 additions and 13 deletions
|
@ -27,20 +27,19 @@
|
|||
(require 'newst-backend)
|
||||
(require 'sawfish)
|
||||
|
||||
(defvar dzen-process nil
|
||||
"Dzen2's process.")
|
||||
|
||||
(defvar dzen-timer nil
|
||||
"Timer used to update the dzen line.")
|
||||
|
||||
(defun get-mail-count (account)
|
||||
(length (directory-files (concat "/home/slash/documents/mail/"
|
||||
account "/inbox/new") nil "^[^.]")))
|
||||
|
||||
(defun dzen-start ()
|
||||
(interactive)
|
||||
(let ((proc (start-process "dzen2" "*dzen2*" "dzen2"
|
||||
"-w" "1920"
|
||||
"-fn" "Monaco-12"
|
||||
"-bg" "#222224"
|
||||
"-fg" "#eeeeec"))
|
||||
(strl (format
|
||||
"%s"
|
||||
(sawfish-eval-expression '(window-name (input-focus)))))
|
||||
(defun dzen-update ()
|
||||
(let ((strl "")
|
||||
(strc metal-express-radio-currently-playing)
|
||||
(strr (format
|
||||
"jabber: %s ryu: %d gm: %d aet: %d 9n: %d rss: %d\n"
|
||||
(oni:current-jabber-status)
|
||||
|
@ -50,12 +49,36 @@
|
|||
(get-mail-count "ninthfloor")
|
||||
(newsticker--stat-num-items-total 'new))))
|
||||
(process-send-string
|
||||
proc (format "^p(_LEFT)%s^p(_RIGHT)^p(-%d)%s"
|
||||
strl (+ 9 (* 9 (length strr))) strr))))
|
||||
"dzen2" (format "%s^p(_CENTER)^p(-%d)%s^p(_RIGHT)^p(-%d)%s"
|
||||
strl
|
||||
(* (floor (/ (length strc) 2)) 8) strc
|
||||
(+ 8 (* 8 (length strr))) strr))))
|
||||
|
||||
(defun dzen-start ()
|
||||
(interactive)
|
||||
(if (or (null dzen-process) (not (process-live-p dzen-process)))
|
||||
(progn
|
||||
(setq dzen-process
|
||||
(start-process "dzen2" "*dzen2*" "dzen2"
|
||||
"-w" "1920"
|
||||
"-fn" "Monaco-10"
|
||||
"-bg" "#222224"
|
||||
"-fg" "#eeeeec"
|
||||
"-y" "1060"))
|
||||
(dzen-update)
|
||||
(setq dzen-timer (run-with-timer 1 1 #'dzen-update)))
|
||||
(message "Dzen2 already running")))
|
||||
|
||||
(defun dzen-stop ()
|
||||
(interactive)
|
||||
(if (and dzen-process (process-live-p dzen-process))
|
||||
(progn
|
||||
(when dzen-timer
|
||||
(cancel-timer dzen-timer))
|
||||
(kill-process "dzen2"))
|
||||
(message "Dzen2 is not running"))
|
||||
(setq dzen-process nil
|
||||
dzen-timer nil))
|
||||
|
||||
(provide 'dzen)
|
||||
;;; dzen.el ends here
|
||||
|
|
Loading…
Reference in a new issue