2020-09-01 11:17:43 +02:00
|
|
|
;;; modeline.el --- Customize my mode-line -*- lexical-binding: t -*-
|
|
|
|
|
2020-07-06 12:11:08 +02:00
|
|
|
;; Author: William Carroll <wpcarro@gmail.com>
|
2020-09-01 11:17:43 +02:00
|
|
|
;; Version: 0.0.1
|
|
|
|
;; Package-Requires: ((emacs "25.1"))
|
2020-07-06 12:11:08 +02:00
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
;; Because I use EXWM, I treat my Emacs mode-line like my system bar: I need to
|
|
|
|
;; quickly check the system time, and I expect it to be at the bottom-right of
|
2020-09-01 14:44:18 +02:00
|
|
|
;; my Emacs frame. I used doom-modeline for awhile, which is an impressive
|
2020-07-06 12:11:08 +02:00
|
|
|
;; package, but it conditionally colorizes on the modeline for the active
|
2020-09-01 14:44:18 +02:00
|
|
|
;; buffer. So if my bottom-right window is inactive, I cannot see the time.
|
2020-07-06 12:11:08 +02:00
|
|
|
;;
|
|
|
|
;; My friend, @tazjin, has a modeline setup that I think is more compatible with
|
|
|
|
;; EXWM, so I'm going to base my setup off of his.
|
|
|
|
|
2020-09-01 14:44:18 +02:00
|
|
|
;;; Code:
|
|
|
|
|
2020-07-06 12:11:08 +02:00
|
|
|
(use-package telephone-line)
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun modeline-bottom-right-window? ()
|
2020-09-01 14:44:18 +02:00
|
|
|
"Determines whether the last (i.e.
|
|
|
|
bottom-right) window of the
|
|
|
|
active frame is showing the buffer in which this function is
|
2020-07-06 12:11:08 +02:00
|
|
|
executed."
|
|
|
|
(let* ((frame (selected-frame))
|
|
|
|
(right-windows (window-at-side-list frame 'right))
|
|
|
|
(bottom-windows (window-at-side-list frame 'bottom))
|
|
|
|
(last-window (car (seq-intersection right-windows bottom-windows))))
|
|
|
|
(eq (current-buffer) (window-buffer last-window))))
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun modeline-maybe-render-time ()
|
2020-09-01 14:44:18 +02:00
|
|
|
"Conditionally renders the `mode-line-misc-info' string.
|
2020-07-06 12:11:08 +02:00
|
|
|
|
|
|
|
The idea is to not display information like the current time,
|
|
|
|
load, battery levels on all buffers."
|
2020-09-01 11:17:43 +02:00
|
|
|
(when (modeline-bottom-right-window?)
|
2020-07-06 12:11:08 +02:00
|
|
|
(telephone-line-raw mode-line-misc-info t)))
|
|
|
|
|
2020-09-01 11:17:43 +02:00
|
|
|
(defun modeline-setup ()
|
2020-07-06 12:11:08 +02:00
|
|
|
"Render my custom modeline."
|
|
|
|
(telephone-line-defsegment telephone-line-last-window-segment ()
|
2020-09-01 11:17:43 +02:00
|
|
|
(modeline-maybe-render-time))
|
2020-07-06 12:11:08 +02:00
|
|
|
;; Display the current EXWM workspace index in the mode-line
|
|
|
|
(telephone-line-defsegment telephone-line-exwm-workspace-index ()
|
2020-09-01 11:17:43 +02:00
|
|
|
(when (modeline-bottom-right-window?)
|
2020-07-06 12:11:08 +02:00
|
|
|
(format "[%s]" exwm-workspace-current-index)))
|
|
|
|
;; Define a highlight font for ~ important ~ information in the last
|
|
|
|
;; window.
|
2020-09-01 14:44:18 +02:00
|
|
|
(defface special-highlight
|
|
|
|
'((t (:foreground "white" :background "#5f627f"))) "")
|
2020-07-06 12:11:08 +02:00
|
|
|
(add-to-list 'telephone-line-faces
|
|
|
|
'(highlight . (special-highlight . special-highlight)))
|
|
|
|
(setq telephone-line-lhs
|
|
|
|
'((nil . (telephone-line-position-segment))
|
|
|
|
(accent . (telephone-line-buffer-segment))))
|
|
|
|
(setq telephone-line-rhs
|
|
|
|
'((accent . (telephone-line-major-mode-segment))
|
|
|
|
(nil . (telephone-line-last-window-segment
|
|
|
|
telephone-line-exwm-workspace-index))))
|
|
|
|
(setq telephone-line-primary-left-separator 'telephone-line-tan-left
|
|
|
|
telephone-line-primary-right-separator 'telephone-line-tan-right
|
|
|
|
telephone-line-secondary-left-separator 'telephone-line-tan-hollow-left
|
|
|
|
telephone-line-secondary-right-separator 'telephone-line-tan-hollow-right)
|
|
|
|
(telephone-line-mode 1))
|
|
|
|
|
|
|
|
(provide 'modeline)
|
2020-09-01 11:17:43 +02:00
|
|
|
;;; modeline.el ends here
|