Skip to content

lucasgruss/exwm-outer-gaps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

EXWM-outer-gaps

Introduction

A lot of window managers provide a feature called “gaps”. It is useless, it is pretty but most importantly it is a feature. And therefore Emacs must have it. Sorry, I don’t make the rules.

This package provides a minor mode to have outer gaps around the workspaces, and some utility functions to control them.

It’s my first elisp package, and I wanted to try my hand at something rather easy. If the code sucks, don’t hesitate to open an issue and tell me why (in fact, please do !).

screenshot.png

Installation

I might go the extra mile and submit it to MELPA someday, but in the meantime I suggest using straight. I personally use Doom Emacs, which has its own package manager based on straight. I have the following in my configuration:

;; in packages.el
(package! exwm-outer-gaps
  :recipe
  (:host github
   :repo "lucasgruss/exwm-outer-gaps"))

;; in config.el
(use-package exwm-outer-gaps
  :after (exwm xelb)
  :config
  (exwm-outer-gaps-mode +1))

I also bind exwm-outer-gaps-mode to a keybinding in order to easily toggle the mode and change dimensions of the gaps.

;; in your config for exwm, you can adapt exwm-input-global-keys
(setq exwm-input-global-keys
      `( ;; ...
        ([?\s-O]  . exwm-outer-gaps-mode)
        ([?\s-p]  . exwm-outer-gaps-increment)
        ([?\s-y]  . exwm-outer-gaps-decrement)
        ;; ...
        ))

Each gap can be set/incremented individually. In my configuration, I also leverage hercules.el in order to create a “menu” that can be invoked to set each gap interactively.

(defvar exwm-outer-gaps-keymap nil
  "keymap to resize gaps")
(setq exwm-outer-gaps-keymap (make-sparse-keymap))

;; map! is a doom specific macro
(map! (:map exwm-outer-gaps-keymap
       :desc "Decrease left" "h" (lambda () (interactive) (exwm-outer-gaps-decrement 0))
       :desc "Increase left" "H" (lambda () (interactive) (exwm-outer-gaps-increment 0))
       :desc "Decrease right" "l" (lambda () (interactive) (exwm-outer-gaps-decrement 1))
       :desc "Increase right" "L" (lambda () (interactive) (exwm-outer-gaps-increment 1))
       :desc "Decrease top" "k" (lambda () (interactive) (exwm-outer-gaps-decrement 2))
       :desc "Increase top" "K" (lambda () (interactive) (exwm-outer-gaps-increment 2))
       :desc "Decrease bottom" "j" (lambda () (interactive) (exwm-outer-gaps-decrement 3))
       :desc "Increase bottom" "J" (lambda () (interactive) (exwm-outer-gaps-increment 3))))

(hercules-def
 :toggle-funs (defun lg/exwm-outer-gaps-menu () (interactive))
 :keymap 'exwm-outer-gaps-keymap
 :transient t)

How it works

There is nothing to write home about, exwm comes with all the facility to implement this. For each exwm workspace (i.e. non-floating frame), there is a workarea that sets its geometry. Usually, each workarea takes up the whole screen/monitor but exwm provides exwm-workspace--update-workareas-hooks that we can use to add gaps.

Since we only have control over the geometry of the frame, the gaps provided by this package are only “outer gaps”, which means that “inner gaps” (gaps between emacs windows) is out of scope for this package. I do intend to write a package for inner gaps in the future by leveraging window-divider-mode and xcb-shape from xelb.

Each side (left, right, top and bottom) has its own gap, so there is some level of granularity available.

There are three user-facing functions that are exwm-outer-gaps-increment, exwm-outer-gaps-decrement and exwm-outer-gaps-balance, which respectively increment all four gaps at the same time, decrement all four gaps and balance all four gaps to be the same width (in case gaps where changed to not be all equal).

About

Provide (useless) gaps to exwm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published