Zane's Blog
Org-mode Conky Colorizer
Tagged as chicken, scheme, org-mode, and con
Just whipped up a little script to colorize my org-mode todo lists for display via Conky. It’s bound to be of use to someone so I thought I’d better share :)
Here’s a screenshot of it in action, sitting in the corner of my desktop.
Source is below, to use, place ${execp /path/to/org-conky-parser.scm 30} in to your conkyrc. Requires Chicken Scheme, and remember to chmod +x the script first.
#!/usr/bin/csi -script
;; org-conky-parser.scm
;; Run an org-mode file through some regexes and output colors
;; Suitable for Conky.
; File to read, could be easily grabbed from argv
(define *file* "~/org/day.org")
(define *font* "Liberation Sans")
;; Code below
(use regex-literals)
(set-read-syntax! #\/ read-regex-literal)
(define ++ string-append)
(define (color c)
(++ "${color " c "}\\1${color}"))
(define (font f)
(++ "${font " f "}\\1${font}"))
(define *replace-list*
(list
(list /^(\*+)/ (color "#555555"))
(list /(TODO)/ (color "#ffaa88"))
(list /(DONE)/ (color "#aaff88"))
(list /(TODO|DONE)/ (font (++ *font* ":style=bold:pixelsize=12")))
(list /(<.*>)/ (color "#aaaaff"))
(list /(<.*>)/ (font (++ *font* ":style=bold:pixelsize=14")))
(list /(.*list.*)/ (font (++ *font* ":style=bold:pixelsize=16")))))
; Grab file contents into a list
(define *contents*
(with-input-from-file *file* read-lines))
; Colorize a line using above regexes
(define (colorize-line line)
(for-each ; Foreach regex/replacement
(lambda (pair)
(set! line (string-substitute (car pair) (cadr pair) line)))
*replace-list*)
line)
(define print-colorized-line (compose print colorize-line))
; Print colorized lines
(for-each print-colorized-line *contents*)
