Skip to content

Instantly share code, notes, and snippets.

@TeMPOraL
Created April 11, 2018 07:13
Show Gist options
  • Save TeMPOraL/4e4e46b7c2dd2b6f3e8a83b91c7e45e1 to your computer and use it in GitHub Desktop.
Save TeMPOraL/4e4e46b7c2dd2b6f3e8a83b91c7e45e1 to your computer and use it in GitHub Desktop.
Some utilities for easier life with multiple heads in StumpWM.
(define-key *top-map* (kbd "s-f") "fselect") ; for faster access to select frame by number
;;; This is like fnext, but restricted to current head only.
(defun focus-next-frame-on-current-head (group)
"Focus next frame, limited to current head."
(let ((current-head (group-current-head group)))
(focus-frame-after group
(remove-if-not (lambda (frame)
(eql (frame-head group frame)
current-head))
(group-frames group)))))
(defcommand (fnext-head tile-group) () ()
"Like `fnext', but only within current head."
(focus-next-frame-on-current-head (current-group)))
(defun focus-current-frame-on-other-head (group)
"Focus first frame on the next head."
(let* ((remaining-heads (cdr (member (group-current-head group) (screen-heads (current-screen)))))
(other-head (if (null remaining-heads)
(first (screen-heads (current-screen)))
(car remaining-heads))))
(focus-frame group (first (remove-if-not (lambda (frame)
(eql (frame-head group frame)
other-head))
(group-frames group))))))
(defcommand (hnext tile-group) () ()
"Switch to next head, focusing on first frame there."
(focus-current-frame-on-other-head (current-group)))
(define-key *top-map* (kbd "s-o") "fnext-head")
(define-key *top-map* (kbd "s-p") "hnext")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment