zk-phi / symon

Tiny graphical system monitor
289 stars 26 forks source link

Graphs are invisible on dark color themes on OSX #19

Closed pierre-lecocq closed 9 years ago

pierre-lecocq commented 9 years ago

(for the record, I'll try to manage it ASAP)

I tested with some of light (dichromacy, light-blue, tango) and dark (deeper-blue, tango-dark, manoj-dark) themes loaded with `load-theme' and the problem seems common to dark themes. At least on Mac OS X.

I've tried solarized-dark and had no problems (color of sparklines inherits 'default face). It may be an environment-dependent problem.

We can probably fix that by just adding :foreground and :background properties to sparklines. can you try this ?

(defadvice symon--make-sparkline (after fix activate)
  (setq ad-return-value
        (nconc ad-return-value '(:foreground "#ffffff"))))
pierre-lecocq commented 9 years ago

After some quick tests, it appears that the :foreground and :background properties of `image' are ignored on Mac OS X.

I tried on GNU/Linux (Debian), it worked, of course.

This is harsh.

zk-phi commented 9 years ago

hmm, how about using xpm images instead of xbm ? if it works on OS X, adding option like symon-sparkline-use-xpm seems reasonable.

pierre-lecocq commented 9 years ago

I'll try this, @zk-phi. Gimme a little bit of time and I'll drop a line here. Thanks

zk-phi commented 9 years ago

here's a sparkline -> xpm converter function.

(defun sparkline->xpm (sparkline)
  (let ((data (plist-get (cdr sparkline) :data)))
    (print data)
    (with-temp-buffer
      (insert (format "/* XPM */
static char * sparkline_xpm[] = { \"%d %d 2 1\", \"@ c %s\", \". c none\""
                      symon-sparkline-width
                      symon-sparkline-height
                      (face-foreground 'default)))
      (dotimes (ix (* symon-sparkline-width symon-sparkline-height))
        (when (zerop (mod ix symon-sparkline-width)) (insert ",\n\""))
        (insert (if (aref data ix) "@" "."))
        (when (zerop (mod (1+ ix) symon-sparkline-width)) (insert "\"")))
      (insert "};")
      `(image :type xpm :data ,(buffer-string) :ascent ,symon-sparkline-ascent
              :height ,symon-sparkline-height :width ,symon-sparkline-width))))

does this work ? (insert-image (sparkline->xpm (symon--make-sparkline '(0 50 100))))

pierre-lecocq commented 9 years ago

Yes it does !

pierre-lecocq commented 9 years ago

screen shot 2015-02-12 at 18 40 43

zk-phi commented 9 years ago

wow! okay, I'll add the option soon.

pierre-lecocq commented 9 years ago

Thanks @zk-phi !

zk-phi commented 9 years ago

committed.

pierre-lecocq commented 9 years ago

Tested. And approved. Works like a charm.

Thanks @zk-phi ! (sorry for the delay, I just finished my day of work. You were faster than me :))