aboutsummaryrefslogtreecommitdiffstats
path: root/oni/home/services
diff options
context:
space:
mode:
authorGravatar Tom Willemse2023-06-20 22:51:40 -0700
committerGravatar Tom Willemse2023-06-20 22:51:40 -0700
commitb775263a344a12c1dadc820cb991e3f50086b209 (patch)
tree83c93b194320b2c086f09e0ff71038e004cd5712 /oni/home/services
parentac08c5edd8f685bf46efdaa5900201533c1ff94a (diff)
downloadnew-dotfiles-b775263a344a12c1dadc820cb991e3f50086b209.tar.gz
new-dotfiles-b775263a344a12c1dadc820cb991e3f50086b209.zip
Add gaps to my stumpwm configuration
I had to copy in and redefine the ‘stumpwm::maximize-window’ function from the ‘swm-gaps’ package because for some reason ‘(frame-width ...)’ returns a ratio on my machine (is it because high-dpi, or ultra-wide? I don't know) and not an integer, which screws up the ‘(setf (xlib:drawable-width ...) ...)’ call.
Diffstat (limited to 'oni/home/services')
-rw-r--r--oni/home/services/stumpwm.scm15
-rw-r--r--oni/home/services/stumpwm/config65
2 files changed, 77 insertions, 3 deletions
diff --git a/oni/home/services/stumpwm.scm b/oni/home/services/stumpwm.scm
index ebda987..13e948e 100644
--- a/oni/home/services/stumpwm.scm
+++ b/oni/home/services/stumpwm.scm
@@ -2,9 +2,12 @@
#:use-module ((gnu services configuration)
#:select (serialize-package
define-configuration))
+ #:use-module ((gnu packages lisp)
+ #:select (sbcl))
#:use-module ((gnu packages wm)
#:select (stumpwm
- stumpish))
+ stumpish
+ sbcl-stumpwm-swm-gaps))
#:use-module ((gnu home services)
#:select (service-type
service-extension
@@ -25,13 +28,19 @@
(package
(package stumpwm)
"Package to use for setting Stumpwm")
+ (gaps-package
+ (package sbcl-stumpwm-swm-gaps)
+ "Package to use for setting Stumpwm Gaps")
(stumpish-package
(package stumpish)
"Package to use for setting Stumpish"))
(define (add-stumpwm-packages config)
- (list (home-stumpwm-configuration-package config)
- (home-stumpwm-configuration-stumpish-package config)))
+ (list sbcl
+ (home-stumpwm-configuration-package config)
+ (list stumpwm "lib")
+ (home-stumpwm-configuration-stumpish-package config)
+ (home-stumpwm-configuration-gaps-package config)))
(define (home-stumpwm-config-files config)
`(("stumpwm/config" ,(local-file "stumpwm/config"))))
diff --git a/oni/home/services/stumpwm/config b/oni/home/services/stumpwm/config
index 7c48a39..ad57226 100644
--- a/oni/home/services/stumpwm/config
+++ b/oni/home/services/stumpwm/config
@@ -2,6 +2,7 @@
(in-package :stumpwm-user)
(require 'swank)
+(require 'swm-gaps)
(set-prefix-key (kbd "s-x"))
@@ -76,6 +77,70 @@ after it has been unlocked."
"%d "))
(mode-line)
+;;; Redefine this function again because for some reason on my system
+;;; `(frame-width ...)' returns a ratio, not an integer, which is not accepted
+;;; by `xlib:drawable-width'.
+(defun stumpwm::maximize-window (win)
+ "Redefined gaps aware maximize function."
+ (multiple-value-bind (x y wx wy width height border stick)
+ (stumpwm::geometry-hints win)
+
+ (let ((ox 0) (oy 0) (ow 0) (oh 0)
+ (frame (stumpwm::window-frame win)))
+ (if (swm-gaps::apply-gaps-p win)
+ (multiple-value-setq (ox oy ow oh) (swm-gaps::gaps-offsets win)))
+
+ ;; Only do width or height subtraction if result will be positive,
+ ;; otherwise stumpwm will crash. Also, only modify window dimensions
+ ;; if needed (i.e. window at least fills frame minus gap).
+ (when (and (< ow width)
+ (>= width (- (frame-width frame) ow)))
+ (setf width (- width ow)))
+ (when (and (< oh height)
+ (>= height (- (frame-height frame) oh)))
+ (setf height (- height oh)))
+
+ (setf x (+ x ox)
+ y (+ y oy))
+
+ ;; This is the only place a window's geometry should change
+ (set-window-geometry win :x wx :y wy :width width :height height :border-width 0)
+ (xlib:with-state ((window-parent win))
+ ;; FIXME: updating the border doesn't need to be run everytime
+ ;; the window is maximized, but only when the border style or
+ ;; window type changes. The overhead is probably minimal,
+ ;; though.
+ (setf (xlib:drawable-x (window-parent win)) x
+ (xlib:drawable-y (window-parent win)) y
+ (xlib:drawable-border-width (window-parent win)) border)
+ ;; the parent window should stick to the size of the window
+ ;; unless it isn't being maximized to fill the frame.
+ (if (or stick
+ (find *window-border-style* '(:tight :none)))
+ (setf (xlib:drawable-width (window-parent win)) (window-width win)
+ (xlib:drawable-height (window-parent win)) (window-height win))
+ (let ((frame (stumpwm::window-frame win)))
+ (setf (xlib:drawable-width (window-parent win)) (- (round (frame-width frame))
+ (* 2 (xlib:drawable-border-width (window-parent win)))
+ ow)
+ (xlib:drawable-height (window-parent win)) (- (stumpwm::frame-display-height (window-group win) frame)
+ (* 2 (xlib:drawable-border-width (window-parent win)))
+ oh))))
+ ;; update the "extents"
+ (xlib:change-property (window-xwin win) :_NET_FRAME_EXTENTS
+ (list wx
+ (- (xlib:drawable-width (window-parent win)) width wx)
+ wy
+ (- (xlib:drawable-height (window-parent win)) height wy))
+ :cardinal 32))
+ (update-configuration win))))
+
+(setf swm-gaps:*head-gaps-size* 0)
+(setf swm-gaps:*inner-gaps-size* 15)
+(setf swm-gaps:*outer-gaps-size* 15)
+
+(swm-gaps:toggle-gaps-on)
+
(restore-from-file "default")
(define-frame-preference "Default"