summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorJakob L. Kreuze2021-06-15 21:55:13 -0400
committerJakob L. Kreuze2021-06-15 21:55:32 -0400
commit0466ca9440810feb2d9f9bd12313d30d4bb54510 (patch)
tree434ca1374f06ff2372cdcf5e48f80e9c39673737 /lisp
parentb72cce68fac68ba76b39462b01fa51087e585e2d (diff)
Remove window-manager.el
Diffstat (limited to 'lisp')
-rw-r--r--lisp/window-manager.el324
1 files changed, 0 insertions, 324 deletions
diff --git a/lisp/window-manager.el b/lisp/window-manager.el
deleted file mode 100644
index 33cc626..0000000
--- a/lisp/window-manager.el
+++ /dev/null
@@ -1,324 +0,0 @@
-;;; window-manager.el -*- lexical-binding: t; -*-
-;;;
-;;; Author: Jakob L. Kreuze <zerodaysfordays@sdf.org>
-;;; URL: https://git.sr.ht/~jakob/.emacs.d/
-;;;
-;;; My configuration for the EXWM package [1]. Yes, I use Emacs as my window
-;;; manager. You should, too!
-;;;
-;;; [1]: https://github.com/ch11ng/exwm
-;;;
-
-(defmacro save-workspace-excursion (&rest body)
- (let ((idx (gensym "idx")))
- `(let ((,idx exwm-workspace-current-index))
- (unwind-protect
- (progn ,@body)
- (exwm-workspace-switch ,idx)))))
-
-(defun start-signald ()
- "Starts signald independently of Pidgin."
- (let ((old-dir default-directory))
- (with-temp-buffer
- (cd "/sudo::/home/jakob/Code/signald")
- (shell-command "mkdir -p /var/run/signald")
- (shell-command "chown jakob: /var/run/signald")
- (cd "/home/jakob/Code/signald")
- (start-process "signald" "*signald*" "/home/jakob/Code/signald/build/install/signald/bin/signald"))
- (cd old-dir)))
-
-(defun setup-pidgin ()
- "Starts Pidgin on the leftmost monitor."
- (interactive)
- (save-workspace-excursion
- (start-signald)
- (exwm-workspace-switch (elt exwm-randr-workspace-order 0))
- (split-window-right 40)
- (start-process-shell-command "Pidgin" nil "pidgin")))
-
-(use-package exwm
- :config
- (exwm-enable)
-
- ;; Set the number of initial workspaces to the number of monitors attached to
- ;; that machine.
- (setq exwm-workspace-number
- (choose-for-machine ("Epsilon" 3)
- ("Upsilon" 1)
- ("Lambda" 1)
- (t 1)))
-
- ;; I like being able to use my X windows across workspaces.
- :init
- (setq exwm-workspace-show-all-buffers t
- exwm-layout-show-all-buffers t)
-
- ;; "Global key bindings" in EXWM work essentially anywhere, including buffers
- ;; that are currently in char mode. I've taken this as an opportunity to
- ;; incorporate windmove to my workflow, now that I have the super key at my
- ;; disposal.
- :config
- (require 'windmove)
-
- ;; Define some interactive functions for dealing with a multi-head setup.
- (when (string= (system-name) "Epsilon")
- (cl-defmacro save-workspace-excursion (n &body body)
- "Execute BODY in EXWM workspace N, then switch back to the
-selected workspace at the time of invocation."
- (let ((old (gensym "old")))
- `(let ((,old exwm-workspace-current-index))
- (unwind-protect
- (progn
- (exwm-workspace-switch ,n)
- ,@body)
- (exwm-workspace-switch ,old)))))
-
- (defvar exwm-randr-workspace-order '(2 0 1)
- "An ordering of how the monitor associated with each
- workspace appears on my desk, from left-to-right.")
-
- ;; (defvar my-windmove-excursions
- ;; (mapcar #'(lambda (workspace)
- ;; (save-workspace-excursion workspace
- ;; (cons workspace (selected-window))))
- ;; exwm-randr-workspace-order)
- ;; "State; last selected window for each monitor workspace.")
-
- (defun my-windmove--left-workspace ()
- "Return the workspace to the left of this one, according to
-`exwm-randr-workspace-order'."
- (let ((index (cl-position exwm-workspace-current-index exwm-randr-workspace-order)))
- (if (> 0 (1- index))
- (car (last exwm-randr-workspace-order))
- (nth (1- index) exwm-randr-workspace-order))))
-
- (defun my-windmove--right-workspace ()
- "Return the workspace to the right of this one, according to
-`exwm-randr-workspace-order'."
- (let ((index (cl-position exwm-workspace-current-index exwm-randr-workspace-order)))
- (if (= (length exwm-randr-workspace-order) (1+ index))
- (cl-first exwm-randr-workspace-order)
- (nth (1+ index) exwm-randr-workspace-order))))
-
- (defun my-windmove--leftmost-window ()
- "Return the window furthest left in the current workspace."
- (let ((positions (mapcar #'(lambda (win)
- (cons win (window-absolute-pixel-edges win)))
- (window-list))))
- (car
- (cl-reduce #'(lambda (a b)
- (cl-destructuring-bind
- ((win1 x1 y1 w1 h1)
- (win2 x2 y2 w2 h2))
- (list a b)
- (if (and (<= x1 x2)
- (<= y1 y2))
- a
- b)))
- positions))))
-
- (defun my-windmove--rightmost-window ()
- "Return the window furthest right in the current workspace."
- (let ((positions (mapcar #'(lambda (win)
- (cons win (window-absolute-pixel-edges win)))
- (window-list))))
- (car
- (cl-reduce #'(lambda (a b)
- (cl-destructuring-bind
- ((win1 x1 y1 w1 h1)
- (win2 x2 y2 w2 h2))
- (list a b)
- (if (and (<= x1 x2)
- (<= y1 y2))
- b
- a)))
- positions))))
-
- (defun my-windmove-right ()
- "`windmove-right' if the buffer to the immediate right is on
-the same frame, otherwise call out to `exwm-workspace-switch'."
- (interactive)
- (cond ((windmove-find-other-window 'right) (windmove-right))
- (t (exwm-workspace-switch (my-windmove--right-workspace))
- (select-window (my-windmove--leftmost-window)))))
-
- (defun my-windmove-left ()
- "`windmove-left' if the buffer to the immediate left is on
-the same frame, otherwise call out to `exwm-workspace-switch'."
- (interactive)
- (cond ((windmove-find-other-window 'left) (windmove-left))
- (t (exwm-workspace-switch (my-windmove--left-workspace))
- (select-window (my-windmove--rightmost-window))))))
-
- ;; And if we haven't defined those functions because we aren't on a multi-head
- ;; setup, define aliases to the underlying windmove functions.
- (when (and (not (fboundp #'my-windmove-left))
- (not (fboundp #'my-windmove-right)))
- (defalias #'my-windmove-left #'windmove-left)
- (defalias #'my-windmove-right #'windmove-right))
-
- (setq exwm-input-global-keys
- `(([?\s-r] . exwm-reset)
- ([?\s-a] . my-windmove-left)
- ([?\s-d] . my-windmove-right)
- ([?\s-w] . windmove-up)
- ([?\s-s] . windmove-down)
- ([?\s-p] . (lambda (&optional arg)
- ;; (interactive (list (read-shell-command "$ ")))
- ;; (start-process-shell-command command nil command))
- (interactive "P")
- (ivy-read "$ " (counsel-linux-apps-list)
- :predicate (unless arg (lambda (x) (get-text-property 0 'visible (car x))))
- :action #'(lambda (prog)
- (if (stringp prog)
- (start-process-shell-command prog nil prog)
- (call-process "gtk-launch" nil 0 nil (cdr prog)))))))
- ([?\s-X] . (lambda ()
- (interactive)
- (start-process "" nil "screen-lock")))
- ([?\s-f] . (lambda ()
- (interactive)
- (start-process "" nil "firefox")))
- ([?\s-P] . setup-pidgin)
- (,(kbd "s-<return>") . shell-same-window)
-
- ([?\s-\"] . eyebrowse-close-window-config)
- ([?\s-,] . eyebrowse-rename-window-config)
- ([?\s-.] . eyebrowse-switch-to-window-config)
-
-
- ;; Keys are offset such that <s-1> corresponds to the 0th workspace.
- ,@(mapcar (lambda (i)
- `(,(kbd (format "s-%d" i)) .
- (lambda ()
- (interactive)
- (eyebrowse-switch-to-window-config ,i))))
- (number-sequence 0 9))
- ,@(mapcar (lambda (i)
- `(,(kbd (format "s-%c" (elt ")!@#$%^&*(" i))) .
- (lambda ()
- (interactive)
- (exwm-workspace-switch
- (elt exwm-randr-workspace-order ,(- i 1))))))
- (number-sequence 1 exwm-workspace-number))))
-
- ;; Ah, yes. Simulation keys, the reason I decided to look at EXWM in the first
- ;; place.
- :init
- (setq exwm-input-simulation-keys
- '(([?\C-b] . [left])
- ([?\M-b] . [C-left])
- ([?\C-f] . [right])
- ([?\M-f] . [C-right])
- ([?\C-p] . [up])
- ([?\C-n] . [down])
- ([?\C-a] . [home])
- ([?\C-e] . [end])
- ([?\M-v] . [prior])
- ([?\C-v] . [next])
- ([?\C-d] . [delete])
- ([?\C-k] . [S-end delete])
-
- ([?\C-w] . [?\C-x])
- ([?\M-w] . [?\C-c])
- ([?\C-y] . [?\C-v])
-
- ([?\C-s] . [?\C-f])))
-
- ;; The tab management functionality of Firefox's Saka Key extension is
- ;; limited, so I'm using simulation keys instead. I've also disabled
- ;; simulation keys for Alacritty because it doesn't play nicely with readline.
- :hook
- (exwm-manage-finish . (lambda ()
- (when (and exwm-class-name
- (string= exwm-class-name "Firefox"))
- (exwm-input-set-local-simulation-keys
- (cl-concatenate 'list
- exwm-input-simulation-keys
- '(([?\C-q] . [?\C-w])))))
- (when (and exwm-class-name
- (string= exwm-class-name "Alacritty"))
- (exwm-input-set-local-simulation-keys nil))))
-
- ;; EXWM's buffers are named '*EXWM*' upon creation, which makes switching
- ;; between windows a pain. This snippet renames buffers when their class or
- ;; title changes.
- :hook
- (exwm-update-class . (lambda ()
- (exwm-workspace-rename-buffer exwm-class-name)))
- (exwm-update-title . (lambda ()
- (when (not exwm-instance-name)
- (exwm-workspace-rename-buffer exwm-title))))
-
-
- ;; Start the Emacs daemon so that 'emacsclient' can be used from the command
- ;; line to pop a new buffer for editing.
- :config
- (server-start)
-
- ;; Configure the resolution of my monitors and let EXWM know about them.
- :config
- (require 'exwm-randr)
- (defun hdmi-out ()
- (and (string= (system-name) "Upsilon")
- (save-window-excursion
- (with-temp-buffer
- (shell-command "xrandr" (current-buffer))
- (cl-search "HDMI-1 connected" (buffer-string))))))
- (setq exwm-randr-workspace-monitor-plist
- (if (string= (system-name) "Epsilon")
- '(0 "DVI-D-0" 1 "HDMI-A-0" 2 "DisplayPort-0")
- '(0 (if (hdmi-out) "HDMI-1" "eDP-1"))))
- (add-hook 'exwm-randr-screen-change-hook
- (lambda ()
- (start-process-shell-command
- "xrandr" nil
- (if (string= (system-name) "Epsilon")
- "xrandr --output DVI-D-0 --primary --left-of HDMI-A-0"
- (if (hdmi-out)
- "xrandr --output HDMI-1 --mode 1920x1080 --output eDP-1 --off"
- "xrandr --output eDP-1 --mode 1920x1080")))))
- (exwm-randr-enable))
-
-;; I have eschewed EXWM's workspace management in favor of Eyebrowse. The EXWM
-;; workspace feature now only sees use for supporting multiple heads in this
-;; configuration.
-
-(use-package eyebrowse
- :config
- (eyebrowse-mode)
- ;; Automatically label some workspaces.
- :config
- (save-workspace-excursion
- (exwm-workspace-switch (elt exwm-randr-workspace-order 0))
- (eyebrowse-rename-window-config 1 "Pidgin")
- (exwm-workspace-switch (elt exwm-randr-workspace-order 1))
- (eyebrowse-rename-window-config 1 "Firefox")
- (eyebrowse-rename-window-config 2 "Work")))
-
-;; Some keybindings for buffer-move that are analagous to my keybindings for
-;; windmove above.
-
-(use-package buffer-move
- :bind
- ("M-s-w" . buf-move-up)
- ("M-s-a" . buf-move-left)
- ("M-s-s" . buf-move-down)
- ("M-s-d" . buf-move-right))
-
-;; EXWM has issues popping any sort of pinentry window, so I just let Emacs do
-;; pinentry's job.
-
-(use-package epa
- :straight nil
- :config
- (setq epg-pinentry-mode 'loopback))
-
-;; And on that note, allow 'gpg-agent' to query Emacs for my passphrase.
-
-(use-package pinentry
- :demand t
- :config
- (setenv "INSIDE_EMACS" (format "%s,comint" emacs-version))
- (pinentry-start))
-

© 2015 - 2026 Jakob L. Kreuze