blob: 9536cfae84a08bc5bf8567dc2756dc04b6552cc9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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)
|