config.phundrak.com/docs/stumpwm/groups.org

3.3 KiB
Raw Blame History

StumpWM — Groups and Placement

StumpWM — Groups and Placement

Groups and Placement

I dont need many groups, rarely more than five. Hence, here are my five default groups.

Groups Number Type
[EMACS] 1 Tiling
[TERM] 2 Tiling
[WWW] 3 Tiling
[PRIV] 4 Tiling
[FILES] 5 Tiling
Five default groups for my StumpWM setup
(let ((make-group (lambda (group &optional first-p)
                    (let ((group-name (car group))
                          (group-type (nth 2 group)))
                      (format "%S" `(,(if first-p 'grename
                                        (pcase group-type
                                          ("Dynamic" 'gnewbg-dynamic)
                                          ("Floating" 'gnewbg-float)
                                          (otherwise 'gnewbg)))
                                     ,group-name))))))
  (string-join `(,(funcall make-group (car groups) t)
                 ,@(mapcar (lambda (group)
                             (funcall make-group group))
                           (cdr groups)))
               "\n"))
(grename "[EMACS]")
(gnewbg "[TERM]")
(gnewbg "[WWW]")
(gnewbg "[PRIV]")
(gnewbg "[FILES]")

Groups are specified this way:

(when *initializing*
  <<gen-groups()>>)

By default, if nothing is specified as per the group type, my groups are manual tiling groups. Otherwise, as you can see above, they can also be dynamic tiling groups or floating groups.

Next, lets make sure no previous window placement rule is in place, this will avoid unexpected and hard-to-debug behaviour.

(clear-window-placement-rules)
(require 'seq)
(let ((output "")
      (rules (seq-filter (lambda (rule) rule)
                         (mapcar (lambda (line)
                                   (let ((classes (caddr line)))
                                     (unless (string= "" classes)
                                       (cons
                                        (split-string classes "," t "[[:space:]]*")
                                        (car line)))))
                                 rules))))
  (progn
    (seq-do (lambda (rule)
              (let ((classes (car rule))
                    (group   (cdr rule)))
                (dolist (class classes)
                  (setf output (format "%s\n%s"
                                       `(define-frame-preference ,(format "\"%s\"" group)
                                          (nil t t :class ,(format "\"%s\"" class)))
                                       output)))))
            rules)
    output))

Dynamic groups, if any is created, should have a split ratio of half of the available space.

(setf *dynamic-group-master-split-ratio* 1/2)