stumpwm-devel
[Top][All Lists]
Advanced

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

[STUMP] Great wm, and getting more modifiers to work


From: Jeremy Hankins
Subject: [STUMP] Great wm, and getting more modifiers to work
Date: Mon, 18 Sep 2006 08:43:33 -0400
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

My first attempt at sending this (via gmane) was held for the moderator
(I've canceled it) because I wasn't subscribed.  Evidently gmane doesn't
know the list is subscribers-only?

First, very interesting window manager!  Thanks!

Second, what needs to be done to get more modifiers (e.g., super) to
work?  I looked things over a bit, but I'm afraid I didn't understand
enough of what's going on.  Pointers to docs are welcome.

Third, I thought I'd share what I've done with it so far, if it's of
interest.  This can be used to, for example, run a single firefox window
and find it with the same command you use to start it.  I'm fairly new
to lisp, and certainly new to common lisp, so suggestions and pointers
are welcome.

(defun goto-win (win)
  "Raise the window win and select its frame.  For now, it does not
select the screen."
  (let* ((screen (window-screen win))
         (frame (window-frame screen win)))
    ;; Select screen?
    (frame-raise-window screen frame win)
    (focus-frame screen frame)))

(defun win-app-info (win)
  "Returns a list containing the class, instance, and title of window."
  (list (window-class win)
        (window-res-name win)
        (window-name win)))

;; Doesn't handle lists of different lengths: extra elements in one list
;; will be ignored.
(defun app-info-cmp (match1 match2)
  "Compare two lists of strings representing window attributes.  If an
element is nil it matches anything."
  (or (not match1)
      (not match2)
      (let ((a (car match1))
            (b (car match2)))
        (and
         (or (not a)
             (not b)
             (string= a b))
         (app-info-cmp (cdr match1) (cdr match2))))))


(defun app (screen cmd &key class instance title)
  "If any of class, title, or instance are set and a matching window can
be found, select it.  Otherwise simply run cmd."
  (let ((win
         ;; If no qualifiers are set don't bother looking for a match.
         (and (or class instance title)
              (find (list class instance title)
                    (screen-mapped-windows screen)
                    :key 'win-app-info
                    :test 'app-info-cmp))))
    (if win
        (goto-win win)
      (run-shell-command cmd))))


(define-stumpwm-command "shell" (screen)
  (app screen "myterm -title '*shell*'" :title "*shell*"))

(define-stumpwm-command "web" (screen)
  (app screen "firefox" :class "mozilla-firefox"))

-- 
Jeremy Hankins <address@hidden>
PGP fingerprint: 748F 4D16 538E 75D6 8333  9E10 D212 B5ED 37D0 0A03





reply via email to

[Prev in Thread] Current Thread [Next in Thread]