SawfishWM / sawfish

Sawfish Window-Manager
GNU General Public License v2.0
162 stars 32 forks source link

match-window: allow specifying arbitrary functions as filter #48

Closed mina86 closed 3 years ago

mina86 commented 3 years ago

Extend the ‘match-window-profile’ syntax such that specifying ‘(cons FUNC ARGS)’ as a filter calls ‘(FUNC WND . ARGS)’ to filter windows and profiles based on criteria different than just window properties.

For example, the following rule applies actions only to the first terminal window:

(define (my-first-terminal-p wnd)
  (let ((is-term (lambda (wnd)
                   (let ((cls (get-x-text-property wnd 'WM_CLASS)))
                     (and cls (string-equal "Term" (aref cls 0)))))))
    (and (is-term wnd)
         (do ((wnds (managed-windows) (cdr wnds)))
             ((or (null wnds)
                  (and (not (eq (car wnds) wnd))
                       (is-term (car wnds))))
              (null wnds))))))

(add-window-matcher `((,my-first-terminal-p))
                    '((position . north-west)))
Nanolx commented 3 years ago

Thanks.