Re: [Sawfish] F1-F12 keybinding on gnome background.

[ Thread Index | Date Index | More lists.tuxfamily.org/sawfish Archives ]


The following code works, except if focus is on the desktop background. (p.s. any advice from looking at my code is appreciated)

Here is the code I used to generate it

;; Use a small library of code included with sawfish by default
;; /usr/share/sawfish/lisp/sawfish/wm/commands/jump-or-exec.jl
(require 'sawfish.wm.commands.jump-or-exec)


;; arg1 - title regex used to locate window
;; arg2  - shell command used to create window
;;  (jump-or-exec-or-last "firefox" "firefox &")
(define (jump-or-exec-or-last re exec)
  "Jump-or-exec, unless the window is already focused, in which case focus last window

  example:

   If a window with the title matching the regex \"Emacs -\" is
   found then jump to it, else run the command \"emacsclient -c\"

   (jump-or-exec-or-last \"Emacs -\" \"emacsclient -c\")

"
  (if (string-match re (window-name (input-focus)))
      (display-window (nth 1 (stacking-order)))
    (jump-or-exec re exec)))


;;  Sample code created by the macro below
;;
;; (define (switch-2-firefox)
;;    "If firefox is open, with a title of \"Vimperator\"
;;     then jump to it. Else create it.

;;     If we are already in that firefox. Jump to last
;;     window we were in"
;;    (interactive)
;;    (jump-or-exec-or-last "Vimperator" "firefox"))


;; Example usage of this macro to create the function  switch-2-facebook
;; (create-switch-2-function "facebook" "acebook" "firefox www.facebook..com")

;; arg1 - arbitrary unique program name/id
;; arg2 - title regex used to locate window
;; arg3 - shell command used to create window


(defmacro create-switch-2-function (program re exec)
 ""
  `(defun ,(read-from-string (concat "switch-2-" program)) ()
     (interactive)
         (jump-or-exec-or-last ,re ,exec)))


;; Create function switch-2-facebook
;;(create-switch-2-function "facebook" "acebook" "firefox www.facebook.com")

;; Run our generated function, that will switch focus to facebook
;; (switch-2-facebook)

;; file: generate-switch-to-functions.jl
;; Generate switch to functions
;; Can be called from bash
;;   $ alias sawl="sawfish-client < $@"
;;   $ alias sawlq="sawfish-client &> /dev/null < $@"
;;   $ sawlq generate-switch-to-functions.jl
----------------------------------------------------------------------------------------------------------------------------
;; TODO: place values in csv file and loop
(create-switch-2-function "facebook" "Facebook -" "firefox www.facebook.com")
(create-switch-2-function "firefox" "Vimperator" "firefox")
(create-switch-2-function "gmail" "Gmail" "firefox www.gmail.com")
(create-switch-2-function "terminal" "dericbytes@slug" "/home/dericbytes/sh/my-terminal")
(create-switch-2-function "emacs" "Emacs -" "emacsclient -c -e \'(fullscreen)\'") 
(create-switch-2-function "pidgin" "Buddy List" "pidgin")


;; switch-2-keymap
(bind-keys global-keymap

"F1" 'switch-2-terminal
"F2" 'switch-2-emacs
"F3" 'switch-2-firefox
)

;; can be used in bash
;; alias e="sawfish-client -e '(switch-2-emacs)'
;; alias g="sawfish-client -e '(switch-2-gmail)'

On 22 April 2012 07:23, Christopher Roy Bratusek <nano@xxxxxxxxxxxxx> wrote:

On Saturday 21 April 2012 23:11:17 Deric Bytes wrote:

cylce-windows never works without modificator.

 

Maybe switch-2-terminal is not properly defined?

 

Maybe you can post it?

 


It still is not working.....  cycle-windows seems to be problematic too

cycle-windows works on Super-F8
cycle-windows does does not work on an F9 or other F keys
system works
jump-or-exec works

(bind-keys global-keymap
  "Super-F8" 'cycle-windows
  "F9" 'cycle-windows
  "F11" '(jump-or-exec "Emacs -" "emacsclient -c")
  "F10" '(system "/usr/bin/urxvt &")
 )


On 21 April 2012 17:14, Christopher Roy Bratusek <nano@xxxxxxxxxxxxx> wrote:

On Saturday 21 April 2012 16:03:02 Deric Bytes wrote:

My global-keymap bindings for the Function keys F1-F12 do not seem to work on the gnome background.
They work if I click on the top gnome panel.
And also work when focus is on a window.
I am using the latest archlinux packages - sawfish 1.8.2, gnome 3.2.1 fallback


(bind-keys global-keymap

"F1" '(switch-2-terminal)
"F2" '(switch-2-emacs)
"F3" '(switch-2-firefox)
"F4" '(switch-2-gmail)
;; NOTE: F5 is usually refresh
)

Dunno what switch-2-terminal is, but maybe

 

"F1" 'switch-2-terminal

 

Regards







Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/