~ilmu/vegur

983d137d4b2e889d6b5f0643099732e450b9a423 — ilmu 1 year, 10 months ago dcd1300
sharing my status
A bootstrap-figs/stumpwm/commands.lisp => bootstrap-figs/stumpwm/commands.lisp +59 -0
@@ 0,0 1,59 @@
#| QUESTLOG

Commands I want:
----------------
Open emacs with stumpwm config file $FILE
Open emacs with sly repl into stumpwm
Chaining commands sequentially             :~: (run-commands cmd1 cmd2 ...)
Query layout left/right/top/down
Switch modes (rebind *top-map*)
Intercept unmodified keys by rebinding in *top-map*
Split frame, close split
Move window between frames and create / close splits as necessary
Move windows in frame to other group
Summon windows from frame in other group as new split (so the stack abstraction)
Name windows / name frames / name groups
Serialize and load / unload for various state
API for datalisp (maybe via swank thread)


|#




;; queries : check whether layout offers motion or if split is required

;; check-window
;; move-focus direction
;; check-window -> (if same (progn split (move-window direct))
;;                          (progn (fprev) ;; moves selection to previous
;;                                 (move-window direction)))


;; splits : make necessary split to perform motion given query
;; split -> exchange-windows in direction of split == moving window with split.

;; only :: removes all splits.
;; remove-split
;; hsplit  (-equally -uniformly)
;; vsplit

;; motions : package queries and splits into useful actions

(defcommand go-left () ()
  )
(defcommand go-right () ()
  )
(defcommand go-up () ()
  )
(defcommand go-down () ()
  )



;; scraps

                     ;; args 
(defcommand dump-top-map () () ;; interactive args
  (with-open-file (s (append-to-path *data-dir* "top-map.sexp") :direction :output)))

M bootstrap-figs/stumpwm/init.lisp => bootstrap-figs/stumpwm/init.lisp +19 -7
@@ 6,20 6,32 @@
(xft:cache-fonts)
(set-font (make-instance 'xft:font :family "DejaVu Sans Mono" :subfamily "Book" :size 11))

(defun append-to-path (path str)
  (pathname (concatenate 'string (namestring path) str)))
#| REGARDING CACHE DIRECTORY

~/.cache is less permanent data, should be recoverable if it is destroyed.
~/.local/share is XDG_DATA_HOME by default, this data is not as transient.  |#

;; utils

(defun show-cache-pathname (filename)
  (uiop:xdg-data-home #p"stumpwm/" filename))

(setf *data-dir* (append-to-path (uiop:xdg-cache-home) "stumpwm/"))
(setf *cfg-dir* (append-to-path (uiop:xdg-config-home) "stumpwm/"))
(defun show-config-pathname (filename)
  (uiop:xdg-config-home #p"stumpwm/" filename))

(defun load-config-file (file)
  (load (append-to-path *cfg-dir* file)))
  (load (show-config-pathname file)))

(load-config-file "keyboard.lisp") ;; caps -> hyper, sort out modifiers.
(load-config-file "lib.lisp")      ;; define various commands that can be bound.
(load-config-file "commands.lisp") ;; define various commands that can be bound.
(load-config-file "swank.lisp")    ;; make it possible to open repl to running stump instance.
(load-config-file "keymap.lisp")     ;; bind commands to keys in keymaps.
(load-config-file "keymap.lisp")   ;; bind commands to keys in keymaps.

#| bind keys to *root-map* for C-t prefixed commands and *top-map* for unprefixed commands.
(stumpwm:define-key stumpwm:*root-map* (stumpwm:kbd "u") "exec kitty")
|#


;; deprecated
(defun append-to-path (path str)
  (pathname (concatenate 'string (namestring path) str)))

A bootstrap-figs/stumpwm/keyboard.lisp => bootstrap-figs/stumpwm/keyboard.lisp +1 -0
@@ 0,0 1,1 @@
;; TODO: when running command `modifiers` have a key for each one of them.

M bootstrap-figs/stumpwm/keymap.lisp => bootstrap-figs/stumpwm/keymap.lisp +61 -0
@@ 1,3 1,6 @@
;; MASSIVE TODO: FIXME.


#| Keymap

*top-map*


@@ 9,6 12,17 @@

The idea is to maintain DSLs for interacting.

STRATEGY
========

The top map has access to launching and rearranging via caps-lock (TODO keyboard.lisp).
There are various modes that can be switched to or accessed via prefix:
- rearrange  : commands defined in lib.lisp (TODO rename commands.lisp)
- resize     : example from stump source code with different bindings
- meta       : datalisp interop, useful for naming, exporting, importing.
- commands (default, not useful)


|#

(define-key *root-map* (kbd "u") "exec chromium")


@@ 20,3 34,50 @@ The idea is to maintain DSLs for interacting.
(define-key *top-map* (kbd "M-l") "fnext")
(define-key *top-map* (kbd "M-j") "next-in-frame")
(define-key *top-map* (kbd "M-k") "prev-in-frame")

#| Modes

Insert mode    :~: default *top-map*
Command mode   :~: default *root-map*
Rearrange mode :~: mode for moving windows between (frames/stacks) and (creating/closing) (splits/frames/stacks).

Okay looks like stump already has the concept of modes.

The *root-map* can be accessed via prefix or by pushing it into *top-map* with `command-mode` command.
Mode is exited with C-g which I suppose is bound to `TODO` command in the *top-map* during `command-mode`.

This file should be a collection of commands that I bind

|#

(define-interactive-keymap (rearrange tile-group) (:on-enter #'enter-rearrange-mode
						   :on-exit #'exit-rearrange-mode
						   :abort-if #'abort-rearrange-mode-p)
  ((kbd "j") "move window up somehow")
  ...)

;; TODO: resize tile-group
;;       use different binds than in stump source.



;; structure of command-mode switch in stump

(defun rearrange-mode-start-message ()
  (message "Press q to exit rearrange-mode."))
(defun rearrange-mode-end-message ()
  (message "Exited rearrange mode"))

(defvar *rearrange-mode-start-hook* '(rearrange-mode-start-message)
  "A hook callled whenever rearrange mode is started")
(defvar *rearrange-mode-end-hook* '(rearrange-mode-end-message)
  "A hook called whenever rearrange mode is ended")

(defcommand rearrange-mode () ()
  "Rearrange mode allows you to invoke StumpWM commands, without prefix, to rearrange windows
   by opening or closing splits as necessary for the frames to contain the moving window in
   relation to all other windows. To exit command mode, type @key{q}."
  (run-hook *rearrange-mode-start-hook*)
  (push-top-map *rearrange-map*))



M bootstrap-figs/stumpwm/lib.lisp => bootstrap-figs/stumpwm/lib.lisp +9 -24
@@ 1,33 1,10 @@
#| Modes

Insert mode    :~: default *top-map*
Rearrange mode :~: 

Okay looks like stump already has the concept of modes.

The *root-map* can be accessed via prefix or by pushing it into *top-map* with `command-mode` command.
Mode is exited with C-g which I suppose is bound to `TODO` command in the *top-map* during `command-mode`.

This file should be a collection of commands that I bind

|#
                     ;; args 
(defcommand dump-top-map () () ;; interactive args
  (with-open-file (s (append-to-path *data-dir* "top-map.sexp") :direction :output)))


(defvar *input-mode* 'insert-mode)
(defvar *rearrange-map* )



#| QUESTLOG

Commands I want:
----------------
Open emacs with stumpwm config file $FILE
Open emacs with sly repl into stumpwm
Chaining commands sequentially
Chaining commands sequentially             :~: (run-commands cmd1 cmd2 ...)
Query layout left/right/top/down
Switch modes (rebind *top-map*)
Intercept unmodified keys by rebinding in *top-map*


@@ 49,3 26,11 @@ API for datalisp (maybe via swank thread)


|#



;; scraps

                     ;; args 
(defcommand dump-top-map () () ;; interactive args
  (with-open-file (s (append-to-path *data-dir* "top-map.sexp") :direction :output)))

M config.scm => config.scm +2 -1
@@ 1,3 1,4 @@
;; TODO: investigate whether to set XDG_DATA_HOME .cache or to keep it at .local/share
(use-modules (gnu))
(use-package-modules wm)
(use-service-modules


@@ 31,7 32,7 @@
            "emacs-evil-collection" "zathura" "zathura-pdf-mupdf"
	    "ungoogled-chromium" "setxkbmap" "font-dejavu" "tree"
            "qutebrowser" "sbcl" "stumpwm" "sbcl-stumpwm-ttf-fonts"
            "sbcl-slynk" "cl-slime-swank" "xterm" "nss-certs"))
            "sbcl-slynk" "cl-slime-swank" "fd" "xterm" "nss-certs"))

      (list `(,stumpwm "lib"))
      %base-packages))