From 7d9cfdbc41c664054963184487907032932c870a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 6 Jul 2020 11:11:08 +0100 Subject: Prefer telephone-line to doom-modeline After growing frustrated with doom-modeline's compatibility with my EXWM setup, I decided to borrow @tazjin's setup, which I find to be much more appealing. --- emacs/.emacs.d/wpc/modeline.el | 64 ++++++++++++++++++++++++++++++++++++++++++ emacs/.emacs.d/wpc/wpc-ui.el | 5 ++-- emacs/default.nix | 2 +- 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 emacs/.emacs.d/wpc/modeline.el (limited to 'emacs') diff --git a/emacs/.emacs.d/wpc/modeline.el b/emacs/.emacs.d/wpc/modeline.el new file mode 100644 index 000000000000..a2dbde6d6f2d --- /dev/null +++ b/emacs/.emacs.d/wpc/modeline.el @@ -0,0 +1,64 @@ +;;; modeline.el --- Customize my Emacs mode-line -*- lexical-binding: t -*- +;; Author: William Carroll + +;;; 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 +;; my Emacs frame. I used doom-modeline for awhile, which is an impressive +;; package, but it conditionally colorizes on the modeline for the active +;; buffer. So if my bottom-right window is inactive, I cannot see the time. +;; +;; 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. + +(use-package telephone-line) + +(defun modeline/bottom-right-window? () + "Determines whether the last (i.e. bottom-right) window of the + active frame is showing the buffer in which this function is + 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)))) + +(defun modeline/maybe-render-time () + "Renders the mode-line-misc-info string for display in the + mode-line if the currently active window is the last one in the + frame. + + The idea is to not display information like the current time, + load, battery levels on all buffers." + (when (modeline/bottom-right-window?) + (telephone-line-raw mode-line-misc-info t))) + +(defun modeline/setup () + "Render my custom modeline." + (telephone-line-defsegment telephone-line-last-window-segment () + (modeline/maybe-render-time)) + ;; Display the current EXWM workspace index in the mode-line + (telephone-line-defsegment telephone-line-exwm-workspace-index () + (when (modeline/bottom-right-window?) + (format "[%s]" exwm-workspace-current-index))) + ;; Define a highlight font for ~ important ~ information in the last + ;; window. + (defface special-highlight '((t (:foreground "white" :background "#5f627f"))) "") + (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) +;; modeline.el ends here diff --git a/emacs/.emacs.d/wpc/wpc-ui.el b/emacs/.emacs.d/wpc/wpc-ui.el index 7b8e2eb9bc11..1243feb0aa38 100644 --- a/emacs/.emacs.d/wpc/wpc-ui.el +++ b/emacs/.emacs.d/wpc/wpc-ui.el @@ -15,6 +15,7 @@ (require 'themes) (require 'device) (require 'laptop-battery) +(require 'modeline) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Configuration @@ -175,9 +176,7 @@ ;; Load a theme (themes/set "Solarized Light") -;; Use the Doom modeline -(use-package 'doom-modeline) -(doom-modeline-mode 1) +(modeline/setup) (provide 'wpc-ui) ;;; wpc-ui.el ends here diff --git a/emacs/default.nix b/emacs/default.nix index 293c7d4da4e9..0003777eda5a 100644 --- a/emacs/default.nix +++ b/emacs/default.nix @@ -47,7 +47,7 @@ let flycheck diminish doom-themes - doom-modeline + telephone-line neotree # TODO: Remove this dependency from my config. which-key ivy -- cgit 1.4.1