 
 ;; These bars regulate the height of the mode-line in GUI Emacs.
 (def-modeline-segment! bar
-  (+doom-modeline--make-xpm
-   (face-background (if (active)
-                        'doom-modeline-bar
-                      'doom-modeline-inactive-bar)
-                    nil t)
-   +doom-modeline-height
-   +doom-modeline-bar-width))
+  (if (display-graphic-p)
+      (+doom-modeline--make-xpm
+       (face-background (if (active)
+                            'doom-modeline-bar
+                          'doom-modeline-inactive-bar)
+                        nil t)
+       +doom-modeline-height
+       +doom-modeline-bar-width)
+    ""))
 
 (def-modeline-segment! eldoc-bar
   "A differently colored bar, to signify an eldoc display."
-  (+doom-modeline--make-xpm
-   (face-background 'doom-modeline-eldoc-bar nil t)
-   +doom-modeline-height
-   +doom-modeline-bar-width))
+  (if (display-graphic-p)
+      (+doom-modeline--make-xpm
+       (face-background 'doom-modeline-eldoc-bar nil t)
+       +doom-modeline-height
+       +doom-modeline-bar-width)
+    ""))
 
 
 ;;


(def-modeline! main
  (bar matches " " buffer-info "  %l:%c %p  " selection-info)
  (buffer-encoding vcs major-mode flycheck))

(def-modeline! eldoc
  (eldoc-bar " " eldoc)

;; Inspired from `powerline's `pl/make-xpm'.
(def-memoized! +doom-modeline--make-xpm (color height width)
  "Create an XPM bitmap."
  (propertize
   " " 'display
   (let ((data (make-list height (make-list width 1)))
         (color (or color "None")))
     (create-image
      (concat
       (format "/* XPM */\nstatic char * percent[] = {\n\"%i %i 2 1\",\n\". c %s\",\n\"  c %s\","
               (length (car data))
               (length data)
               color
               color)
       (apply #'concat
              (cl-loop with idx = 0
                       with len = (length data)
                       for dl in data
                       do (cl-incf idx)
                       collect
                       (concat "\""
                               (cl-loop for d in dl
                                        if (= d 0) collect (string-to-char " ")
                                        else collect (string-to-char "."))
                               (if (eq idx len) "\"};" "\",\n")))))
      'xpm t :ascent 'center))))

(defsubst +doom-modeline--buffer-file ()
  "Display the base of the current buffer's filename."
