Next: , Up: External Applications   [Contents][Index]


21.1 Application Invocation

See also the lisp function system which invokes a command from a shell. (see Shell Commands in The Librep Manual)

Function: jump-or-exec regex prog #!key match-class onfocused

Jump to a window, or if it doesn’t exist, start a program. Main use of this function is as a binding to keys. Defined in the module sawfish.wm.commands.jump-or-exec.

Window is searched by matching the name with a regex regex. If booleanmatch-class is non-nil, the value of regex is matched with window’s WM_CLASS. When no window matches, action specified by prog is taken.

If prog is a string, then it should be a program name, and executed from a shell in the background. (I.e. Sawfish adds ”&”.) Otherwise, it should be one of a function, command name, or lisp expression. The function is called without any argument. The lisp expression will be evaluated in the user module.

If the optional argument onfocused is non-nil, it defines the action when the window is already focused, in the same manner as prog, but the function will receive the focused windows as the argument. This can’t be a string.

;; Examples:

;; Jump to a window named "Geany". When not found, invoke "geany" 
;; from a shell.
(bind-keys global-keymap "W-F10"
  '(jump-or-exec "Geany" "geany"))

;; Jump to a window with the class "Gnome-run-dialog".
(bind-keys global-keymap "W-F2"
  '(jump-or-exec "Gnome-run-dialog" "/usr/local/bin/gnome-run-dialog" #:match-class t ))
Function: toggle-or-exec regex prog #!key match-class

This function adds to jump-or-exec by turning a window to “quake”-like "toggle-windows". That means, if this function is invoked on a matching window, that window will be iconified. Else it works in the same way as jump-or-exec.

You may also want to use a window property iconify-on-leave. (see Iconifying Windows.)

;; Examples:

;; Application "dolphin", matched by its name (i.e. WM_NAME.)
;; Press "Home" key, and
;; * if no instance of dolphin is running, it's invoked.
;; * if one is there, the focus jumps to it.
;; * if it's already focused, it will be iconified.
;;
;;  ( bind-keys global-keymap "Home" 
;;    `( toggle-or-exec "Dolphin" "dolphin ~" )

;; "konsole", matched by its window-class (= WM_CLASS).
;;  ( bind-keys global-keymap "F12"
;;    `( toggle-or-exec "Konsole" "konsole" #:match-class t ) 

Next: , Up: External Applications   [Contents][Index]