mirror of
https://github.com/SqrtMinusOne/exwm-modeline.git
synced 2025-12-10 14:35:14 +03:00
Compare commits
10 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c933baccb8 | |||
| f72e65818f | |||
| a29f4c6408 | |||
| 852a88a587 | |||
|
|
6db0e09dc2 | ||
| 3225ec1803 | |||
| 86bce1d910 | |||
| e6aace0235 | |||
| 4c77d4e3df | |||
| 8aaa57d973 |
2 changed files with 40 additions and 15 deletions
10
README.org
10
README.org
|
|
@ -1,5 +1,7 @@
|
||||||
#+TITLE: exwm-modeline
|
#+TITLE: exwm-modeline
|
||||||
|
|
||||||
|
[[https://melpa.org/#/exwm-modeline][file:https://melpa.org/packages/exwm-modeline-badge.svg]]
|
||||||
|
|
||||||
A modeline segment to display exwm workspaces.
|
A modeline segment to display exwm workspaces.
|
||||||
|
|
||||||
Here's how it looks near the list of [[https://github.com/nex3/perspective-el][perspectives]] (the segment of the current package is to the left):
|
Here's how it looks near the list of [[https://github.com/nex3/perspective-el][perspectives]] (the segment of the current package is to the left):
|
||||||
|
|
@ -13,15 +15,11 @@ Features:
|
||||||
- Numbers are clickable.
|
- Numbers are clickable.
|
||||||
|
|
||||||
* Installation
|
* Installation
|
||||||
As the package isn't yet available anywhere but in this repository, you can clone the repository, add it to the =load-path=, and =require= the package:
|
The package is available on MELPA. Install it however you usually install packages, I use [[https://github.com/jwiegley/use-package][use-package]] and [[https://github.com/raxod502/straight.el][straight.el]]:
|
||||||
#+begin_src emacs-lisp
|
|
||||||
(require 'exwm-modeline)
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
My preferred way is to use =use-package= with =straight=:
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package exwm-modeline
|
(use-package exwm-modeline
|
||||||
:straight (:host github :repo "SqrtMinusOne/exwm-modeline")
|
:straight t
|
||||||
:after (exwm))
|
:after (exwm))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
;;; exwm-modeline.el --- A modeline segment for EXWM workspaces -*- lexical-binding: t -*-
|
;;; exwm-modeline.el --- A modeline segment for EXWM workspaces -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2021 Korytov Pavel
|
;; Copyright (C) 2021-2023 Korytov Pavel
|
||||||
;; Copyright (C) 2021 Ellis Kenyő
|
;; Copyright (C) 2021 Ellis Kenyő
|
||||||
;; Copyright (C) 2008-2020 Natalie Weizenbaum <nex342@gmail.com>
|
;; Copyright (C) 2008-2020 Natalie Weizenbaum <nex342@gmail.com>
|
||||||
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
;; Maintainer: Korytov Pavel <thexcloud@gmail.com>
|
;; Maintainer: Korytov Pavel <thexcloud@gmail.com>
|
||||||
;; Version: 0.1.3
|
;; Version: 0.1.3
|
||||||
;; Package-Requires: ((emacs "27.1") (exwm "0.26"))
|
;; Package-Requires: ((emacs "27.1") (exwm "0.26"))
|
||||||
;; Homepage: https://github.com/SqrtMinusOne/pomm.el
|
;; Homepage: https://github.com/SqrtMinusOne/exwm-modeline
|
||||||
|
;; Published-At: 2021-12-22
|
||||||
|
|
||||||
;; This file is NOT part of GNU Emacs.
|
;; This file is NOT part of GNU Emacs.
|
||||||
|
|
||||||
|
|
@ -37,6 +38,8 @@
|
||||||
;; Take a look at `exwm-modeline-mode' for more info.
|
;; Take a look at `exwm-modeline-mode' for more info.
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
(eval-when-compile
|
||||||
|
(require 'cl-lib))
|
||||||
(require 'exwm)
|
(require 'exwm)
|
||||||
(require 'exwm-randr)
|
(require 'exwm-randr)
|
||||||
(require 'exwm-workspace)
|
(require 'exwm-workspace)
|
||||||
|
|
@ -63,7 +66,8 @@ workspaces."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:set (lambda (sym value)
|
:set (lambda (sym value)
|
||||||
(set-default sym value)
|
(set-default sym value)
|
||||||
(exwm-modeline-update)))
|
(when (bound-and-true-p exwm-modeline-mode)
|
||||||
|
(exwm-modeline-update))))
|
||||||
|
|
||||||
(defcustom exwm-modeline-randr t
|
(defcustom exwm-modeline-randr t
|
||||||
"When set, only show workspaces on the current monitor."
|
"When set, only show workspaces on the current monitor."
|
||||||
|
|
@ -71,7 +75,8 @@ workspaces."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:set (lambda (sym value)
|
:set (lambda (sym value)
|
||||||
(set-default sym value)
|
(set-default sym value)
|
||||||
(exwm-modeline-update)))
|
(when (bound-and-true-p exwm-modeline-mode)
|
||||||
|
(exwm-modeline-update))))
|
||||||
|
|
||||||
(defcustom exwm-modeline-display-urgent t
|
(defcustom exwm-modeline-display-urgent t
|
||||||
"When set, display the urgent status in the modeline.
|
"When set, display the urgent status in the modeline.
|
||||||
|
|
@ -82,8 +87,8 @@ switch, so the number of updates is increased significantly."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:set (lambda (sym value)
|
:set (lambda (sym value)
|
||||||
(set-default sym value)
|
(set-default sym value)
|
||||||
(exwm-modeline-update)
|
(when (bound-and-true-p exwm-modeline-mode)
|
||||||
(when exwm-modeline-mode
|
(exwm-modeline-update)
|
||||||
(if value
|
(if value
|
||||||
(progn
|
(progn
|
||||||
(advice-add #'exwm--update-hints :after #'exwm-modeline--urgency-advice)
|
(advice-add #'exwm--update-hints :after #'exwm-modeline--urgency-advice)
|
||||||
|
|
@ -91,6 +96,20 @@ switch, so the number of updates is increased significantly."
|
||||||
(advice-remove #'exwm--update-hints #'exwm-modeline--urgency-advice)
|
(advice-remove #'exwm--update-hints #'exwm-modeline--urgency-advice)
|
||||||
(remove-hook 'exwm-workspace-switch-hook #'exwm-modeline--urgency-advice)))))
|
(remove-hook 'exwm-workspace-switch-hook #'exwm-modeline--urgency-advice)))))
|
||||||
|
|
||||||
|
(defcustom exwm-modeline-workspace-index-map 'exwm-workspace-index-map
|
||||||
|
"Function for mapping a workspace index to a string for display.
|
||||||
|
|
||||||
|
If the value if 'exwm-workspace-index-map, dereference the
|
||||||
|
`exwm-workspace-index-map'variable. Otherwise, use a function."
|
||||||
|
:group 'exwm-workspace
|
||||||
|
:type '(choice
|
||||||
|
(symbol exwm-workspace-index-map :tag "Use EXWM default")
|
||||||
|
(function))
|
||||||
|
:set (lambda (sym value)
|
||||||
|
(set-default sym value)
|
||||||
|
(when (bound-and-true-p exwm-modeline-mode)
|
||||||
|
(exwm-modeline-update))))
|
||||||
|
|
||||||
(defface exwm-modeline-current-workspace
|
(defface exwm-modeline-current-workspace
|
||||||
;; I'd rather :inherit and override warning there, but well
|
;; I'd rather :inherit and override warning there, but well
|
||||||
`((t :foreground ,(face-foreground 'warning) :weight bold))
|
`((t :foreground ,(face-foreground 'warning) :weight bold))
|
||||||
|
|
@ -125,6 +144,14 @@ Always return nil if `exwm-modeline-display-urgent' is not set."
|
||||||
if (eq frame (buffer-local-value 'exwm--frame (cdr item)))
|
if (eq frame (buffer-local-value 'exwm--frame (cdr item)))
|
||||||
return t))
|
return t))
|
||||||
|
|
||||||
|
(defun exwm-modeline--workspace-index-map (i)
|
||||||
|
"Map the workspace index I to a string for display.
|
||||||
|
|
||||||
|
See `exwm-modeline-workspace-index-map' for behaviour."
|
||||||
|
(if (eq exwm-modeline-workspace-index-map 'exwm-workspace-index-map)
|
||||||
|
(funcall exwm-workspace-index-map i)
|
||||||
|
(funcall exwm-modeline-workspace-index-map i)))
|
||||||
|
|
||||||
(defun exwm-modeline--click (event)
|
(defun exwm-modeline--click (event)
|
||||||
"Process a click EVENT on the modeline segment."
|
"Process a click EVENT on the modeline segment."
|
||||||
(interactive "e")
|
(interactive "e")
|
||||||
|
|
@ -132,7 +159,7 @@ Always return nil if `exwm-modeline-display-urgent' is not set."
|
||||||
(target
|
(target
|
||||||
(cl-loop with name = (format "%s" (car (posn-string (event-start event))))
|
(cl-loop with name = (format "%s" (car (posn-string (event-start event))))
|
||||||
for i from 0 to (1- (length exwm-workspace--list))
|
for i from 0 to (1- (length exwm-workspace--list))
|
||||||
if (string-equal (funcall exwm-workspace-index-map i) name)
|
if (string-equal (exwm-modeline--workspace-index-map i) name)
|
||||||
return i))
|
return i))
|
||||||
(exwm-workspace-switch target)))
|
(exwm-workspace-switch target)))
|
||||||
|
|
||||||
|
|
@ -148,8 +175,8 @@ Always return nil if `exwm-modeline-display-urgent' is not set."
|
||||||
WORKSPACE-LIST is the list of frames to display."
|
WORKSPACE-LIST is the list of frames to display."
|
||||||
(cl-loop for frame in workspace-list
|
(cl-loop for frame in workspace-list
|
||||||
for i from 0 to (length workspace-list)
|
for i from 0 to (length workspace-list)
|
||||||
for workspace-name = (funcall exwm-workspace-index-map
|
for workspace-name = (exwm-modeline--workspace-index-map
|
||||||
(exwm-workspace--position frame))
|
(exwm-workspace--position frame))
|
||||||
with current-frame = (selected-frame)
|
with current-frame = (selected-frame)
|
||||||
if (= i 0) collect (nth 0 exwm-modeline-dividers)
|
if (= i 0) collect (nth 0 exwm-modeline-dividers)
|
||||||
collect
|
collect
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue