diff options
author | bd <bdunahu@operationnull.com> | 2025-06-03 14:20:26 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-06-03 14:20:26 -0400 |
commit | e4e27dc11a20eeebf06eed83bbc5d150ee53b846 (patch) | |
tree | 3e90ea76c1a934f6c747eca5d1bef3519d7a7f29 /.config/emacs/libraries/exwm-outer-gaps.el | |
parent | a6a27b6a96a5ab581a36ab7a2cc2b3c297862119 (diff) |
Add useless gaps to exwm
Diffstat (limited to '.config/emacs/libraries/exwm-outer-gaps.el')
-rw-r--r-- | .config/emacs/libraries/exwm-outer-gaps.el | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/.config/emacs/libraries/exwm-outer-gaps.el b/.config/emacs/libraries/exwm-outer-gaps.el new file mode 100644 index 0000000..9536cfa --- /dev/null +++ b/.config/emacs/libraries/exwm-outer-gaps.el @@ -0,0 +1,77 @@ +;;; -*- lexical-binding: t; -*- +;;; Commentary: + +;; modified version of https://github.com/lucasgruss/exwm-outer-gaps + +;;; Code: + + +(require 'exwm-workspace) +(require 'exwm-core) +(require 'exwm) +(require 'xelb) +(require 'xcb) + +(defgroup exwm-outer-gaps nil + "Outer gaps for exwm." + :group 'appearance + :prefix "exwm-outer-gaps") + +(defcustom exwm-outer-gaps-width 15 + "Width between the edge of the monitor and emacs frame for all sides.") + +(defcustom exwm-outer-gaps-increment-step 5 + "Default increment/decrement value for gaps.") + +(defcustom exwm-outer-max-gaps-width + (* exwm-outer-gaps-increment-step 20) + "The maximum size of the gaps.") + +(defun exwm-outer-gaps-compute-gaps () + "Hook to be ran after exwm-workspace--update-workareas-hook" + (let (workareas frames) + (dolist (w exwm-workspace--workareas) + (setf (aref w 3) (+ (aref w 3) exwm-outer-gaps-width) + (aref w 4) (+ (aref w 4) exwm-outer-gaps-width) + (aref w 5) (- (aref w 5) (* 2 exwm-outer-gaps-width)) + (aref w 6) (- (aref w 6) (* 2 exwm-outer-gaps-width)))))) + +(defun exwm-outer-gaps-apply () + "Function used to apply gaps to the emacs frames." + (exwm-workspace--update-workareas) + (dolist (f exwm-workspace--list) + (exwm-workspace--set-fullscreen f))) + +(defun exwm-outer-gaps-set (width) + "Sets the gap width to WIDTH. Automatically clamps the size of the gaps +from 0 to `exwm-outer-max-gaps-width'" + (setq exwm-outer-gaps-width + (max 0 (min width exwm-outer-max-gaps-width)))) + +(defun exwm-outer-gaps-increment () + "Increment the outer gaps by exwm-outer-gaps-increment-step" + (interactive) + (when exwm-outer-gaps-mode + (exwm-outer-gaps-set (+ exwm-outer-gaps-width exwm-outer-gaps-increment-step)) + (exwm-outer-gaps-apply))) + +(defun exwm-outer-gaps-decrement () + "Decrement the outer gaps by exwm-outer-gaps-increment-step" + (interactive) + (when exwm-outer-gaps-mode + (exwm-outer-gaps-set (- exwm-outer-gaps-width exwm-outer-gaps-increment-step)) + (exwm-outer-gaps-apply))) + +;;;###autoload +(define-minor-mode exwm-outer-gaps-mode + "Add useless outer gaps to exwm." + :global t + (if exwm-outer-gaps-mode + (add-hook 'exwm-workspace--update-workareas-hook + #'exwm-outer-gaps-compute-gaps) + (remove-hook 'exwm-workspace--update-workareas-hook + #'exwm-outer-gaps-compute-gaps)) + (exwm-outer-gaps-apply)) + + +(provide 'exwm-outer-gaps) |