[StumpWM] Less groups, only one automatic window placement

This commit is contained in:
Lucien Cartier-Tilet 2021-12-12 15:06:42 +01:00
parent 69a12a3d4a
commit 78fba911e7
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -572,16 +572,12 @@ Ive been used to ten groups, or workspaces, or tags, since I began
using tiling window managers. I shall then continue this habit. Here using tiling window managers. I shall then continue this habit. Here
is the list of groups I will be using: is the list of groups I will be using:
#+name: list-groups #+name: list-groups
| Groups | Number | Windows | Type | | Groups | Number | Windows | Type |
|---------+--------+---------------------+---------| |---------+--------+---------+------|
| [DEV] | 1 | Emacs, Virt-manager | | | [DEV] | 1 | | |
| [SYS] | 2 | | Dynamic | | [PRIV] | 4 | | |
| [WWW] | 3 | Firefox | | | [WWW] | 2 | | |
| [FILES] | 4 | Nemo | | | [FILES] | 3 | Nemo | |
| [MEDIA] | 5 | Gimp | |
| [SOC] | 6 | Signal, discord | |
| [PRIV] | 7 | | |
| [GAM] | 8 | Steam | |
#+name: gen-groups #+name: gen-groups
#+headers: :exports none #+headers: :exports none
@ -589,14 +585,12 @@ is the list of groups I will be using:
(let ((make-group (lambda (group &optional first-p) (let ((make-group (lambda (group &optional first-p)
(let ((group-name (car group)) (let ((group-name (car group))
(group-type (nth 3 group))) (group-type (nth 3 group)))
(format "(%s \"%s\")" (format "%S" `(,(if first-p 'grename
(if first-p (pcase group-type
"grename" ("Dynamic" 'gnewbg-dynamic)
(pcase group-type ("Floating" 'gnewbg-float)
("Dynamic" "gnewbg-dynamic") (otherwise 'gnewbg)))
("Floating" "gnewbg-float") ,group-name))))))
(otherwise "gnewbg")))
group-name)))))
(string-join `(,(funcall make-group (car groups) t) (string-join `(,(funcall make-group (car groups) t)
,@(mapcar (lambda (group) ,@(mapcar (lambda (group)
(funcall make-group group)) (funcall make-group group))
@ -604,15 +598,11 @@ is the list of groups I will be using:
"\n")) "\n"))
#+end_src #+end_src
#+RESULTS[212d0f619fcfa8df9da1b051a3855491e53431b2]: gen-groups #+RESULTS[f5228a3752415c3d4dac5ce26ea36cc1cd74b21c]: gen-groups
: (grename "[DEV]") : (grename "[DEV]")
: (gnewbg-dynamic "[SYS]") : (gnewbg "[PRIV]")
: (gnewbg "[WWW]") : (gnewbg "[WWW]")
: (gnewbg "[FILES]") : (gnewbg "[FILES]")
: (gnewbg "[MEDIA]")
: (gnewbg "[SOC]")
: (gnewbg "[PRIV]")
: (gnewbg "[GAM]")
Groups are specified this way: Groups are specified this way:
#+begin_src lisp #+begin_src lisp
@ -660,46 +650,13 @@ class, so it will be pretty straightforward to the corresponding code.
#+end_src #+end_src
This can be written this way: This can be written this way:
#+RESULTS[4affc294b6e643c957fceec5e084fae4933ac7f3]: gen-rules #+RESULTS[10defc1f5329a09215335793aaca66ca84449df7]: gen-rules
#+begin_src lisp #+begin_src lisp
(define-frame-preference "[GAM]" (nil t t :class "Steam"))
(define-frame-preference "[SOC]" (nil t t :class "discord"))
(define-frame-preference "[SOC]" (nil t t :class "Signal"))
(define-frame-preference "[MEDIA]" (nil t t :class "Gimp"))
(define-frame-preference "[FILES]" (nil t t :class "Nemo")) (define-frame-preference "[FILES]" (nil t t :class "Nemo"))
(define-frame-preference "[WWW]" (nil t t :class "Firefox"))
(define-frame-preference "[DEV]" (nil t t :class "Virt-manager"))
(define-frame-preference "[DEV]" (nil t t :class "Emacs"))
#+end_src #+end_src
Now, lets do some automation. The reason why I want the first group Dynamic groups, if any is created, should have a split ratio of half
to be a dynamic group is so that all terminal windows Ill have there of the available space.
will be automatically arranged. If I switch to the ~[SYS]~ group, I want
three terminal windows to open by default:
- an ~htop~ window
- and two terminals
This can be done like so:
#+begin_src lisp
(defun my-term-init (current-group _last-group)
"Create terminals in the first group when none are already there."
(let ((term-group (select-group (current-screen) "2"))
(windows (group-windows current-group)))
(when (and (equal current-group term-group)
(null windows))
(unless (= 1 (length (group-frames current-group)))
(only))
(term "btm -T")
(term)
(term))))
#+end_src
Lets add a hook for that now:
#+begin_src lisp
(add-hook *focus-group-hook* 'my-term-init)
#+end_src
By the way, dynamic groups should have a split ratio of half of the
available space.
#+begin_src lisp #+begin_src lisp
(setf *dynamic-group-master-split-ratio* 1/2) (setf *dynamic-group-master-split-ratio* 1/2)
#+end_src #+end_src