Re: window list snapshot?



Er, I didn't see anything during a quick search, so I wrote 
something to do it.  It took a while to figure out how to write 
standalone sawfish scripts, but after looking through the source 
for sawfish-client, I got it working.  The librep manual is 
helpful too, even if not totally straightforward.

Anyway, the script is attached.  It just lists all open windows, 
organized by desktop.

I stick this in a fairly simple loop to dump window titles every 
so often, and then I can easily remember what I was running if 
X11 dies or if I have to log out.


-- Scott
#!/bin/sh
exec rep "$0" "$@"
!#

; TODO: sort windows by position and stacking order

(require 'sawfish.client)

(define (exit n) (throw 'quit n))

(defun dump-windows (windows)
  (unless (null windows)
    (dump-window (car windows))
    (dump-windows (cdr windows))
    )
  )

(defun dump-window (w)
  (let* (
         (name (sawfish-client-eval 
                 `(window-full-name (get-window-by-id ',w))))
         (size (sawfish-client-eval 
                 `(window-dimensions (get-window-by-id ',w))))
         (wid (car size))
         (hgt (cdr size))
         (pos (sawfish-client-eval 
                 `(window-position (get-window-by-id ',w))))
         (x (car pos))
         (y (cdr pos))
         )
    (format standard-output "\t%s\t(%sx%s+%s+%s)\n" name wid hgt x y)
    )
  )

(defun dump-workspace (ws)
  (let* (
         (per-column (sawfish-client-eval `pager-workspaces-per-column))
         (x (1+ (quotient ws per-column)))
         (y (1+ (remainder ws per-column)))
         )
    (format standard-output "(%s,%s)\n" x y)
    (dump-windows (sawfish-client-eval `(mapcar window-id (workspace-windows ',ws))))
    )
  )

(defun dump-workspaces (workspaces)
  (unless (null workspaces)
    (dump-workspace (car workspaces))
    (dump-workspaces (cdr workspaces))
    )
  )

(defun dump-all-windows ()
  (dump-workspaces (sort (sawfish-client-eval `(all-workspaces))))
  )

(dump-all-windows)
(exit 0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]