add .local
[hombase.git] / .sawfishrc
blobdca8cf05f1cb4fe0805ad0e52e1b76d03ec54eee
1 ;; viewport options
3 (require 'rep.io.timers)
4 (require 'waffle)
5 (waffle-initialize)
7 (require 'jump-or-exec)
8 (bind-keys global-keymap
9            "H-i" `(jump-or-exec "GVIM"
10                                 ,(lambda ()
11                                    (system "gvim -f &"))
12                                 ,(lambda (wind)
13                                    (display-window wind))))
14 (bind-keys global-keymap
15            "H-y" `(jump-or-exec "^.*@.*:.*$"
16                                 ,(lambda ()
17                                    (system "xterm &"))
18                                 ,(lambda (wind)
19                                    (display-window wind))))
20 (bind-keys global-keymap
21            "H-z" `(jump-or-exec "Mozilla"
22                                 ,(lambda ()
23                                    (system "/usr/local/firefox/firefox &"))
24                                 ,(lambda (wind)
25                                    (display-window wind))))
26 (bind-keys global-keymap
27            "H-m" `(jump-or-exec "emelFM2"
28                                 ,(lambda ()
29                                    (system "emelfm2 &"))
30                                 ,(lambda (wind)
31                                    (display-window wind))))
33 (define-match-window-setter 'keymap-trans
34   (lambda (w prop value)
35     (declare (unused prop))
36     (let ((keymap (or (window-get w 'keymap)
37                       (window-put w 'keymap (copy-sequence window-keymap)))))
38       (mapcar
39        (lambda (pair)         ; pair of from and to keys
40          (bind-keys
41           keymap (car pair)
42           (lambda () (interactive)
44             (if (string-match (cadr pair) (window-name w))
45               (synthesize-event (lookup-event (caddr pair)) (input-focus))
46               )
47             ;(if (string-match (cadr pair) "shell")
48               ;(delete-window-safely w)
49               ;)
50             (make-timer 
51              (lambda ()
52                 (if (string-match (cadddr pair) (window-name w))
53                   (synthesize-event (lookup-event (car(cddddr pair))) (input-focus)
54                    )
55                   )
56                )
57                0 80)
58             (make-timer 
59              (lambda ()
60                 (if (string-match (cadr(cddddr pair)) (window-name w))
61                   (synthesize-event (lookup-event (caddr(cddddr pair))) (input-focus)
62                    )
63                   )
64                )
65                0 80)
67             )))
68        value))))
71 ;(add-window-matcher 'WM_CLASS "^Gvim/gvim$"
72                     ;'(keymap-trans . (("C-SPC" ".*GVIM.*i.* " "F2" ".*GVIM.*" "C-SPC") 
73                                       ;("ESC" ".*GVIM.*i c" "C-SPC" ".*GVIM.*i.* D" "F12" ".*GVIM.*" "ESC")
74                                       ;("i" ".*GVIM.*" "i"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
75                                       ;("o" ".*GVIM.*" "o"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
76                                       ;("a" ".*GVIM.*" "a"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
77                                       ;("C" ".*GVIM.*" "C"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
78                                       ;("O" ".*GVIM.*" "O"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
79                                       ;("I" ".*GVIM.*" "I"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
80                                       ;("$" ".*GVIM.*" "$"  ".*GVIM.*i c U" "C-SPC" ".*GVIM.*i.* U" "F12")
81                                       ;)))
83 ;(add-window-matcher 'WM_NAME "^View Items$"
84                     ;'(keymap-trans . (("x" "shell" "delete-window-safely" "test"))))
85 (add-window-matcher 'WM_CLASS "^emelfm2/main$"
86                     '(keymap-trans . (("C-/" ".*emelFM2.*" "." ".*emelFM2.*" "BS"))))
87 ;(add-window-matcher 'WM_CLASS "^Gvim/gvim$"
88                     ;'(keymap-trans . (("esc" "esc" "C-SPC"))))
89 ;(add-window-matcher 'WM_NAME "*GVIM* i c$"
90                     ;'(keymap-trans . (("C-SPC" "C-F2") )))
91 ;(add-window-matcher 'WM_CLASS "^Firefox-bin/Gecko$"
92                     ;'(keymap-trans . (("H-j" "Down") ("H-k" "Up"))))
93 ;(add-window-matcher 'WM_CLASS "*"
94                     ;'(keymap-trans . (("H-j" "Down") ("H-k" "Up"))))
96 ;(require 'switch-viewports)
97 ;(bind-keys global-keymap "M-C-j" 'switch-viewport-up)
99 ;(require 'viewport-scrolling)
100 ;(bind-keys global-keymap "M-C-j" 'scroll-viewport-up)
102 ;(bind-keys window-keymap "C-M-j" 'pack-window-down)
103 ;(bind-keys window-keymap "C-M-k" 'pack-window-up)
104 ;(bind-keys window-keymap "C-M-h" 'pack-window-left)
105 ;(bind-keys window-keymap "C-M-l" 'pack-window-right)
107 ;(set-number-of-workspaces 2)
109 ;(define-special-variable viewport-dimensions '(2 . 2)
110 ;    "Size of each virtual workspace.")
112 ;(define-special-variable uniconify-to-current-viewport t
113     ;"Windows uniconify to the current viewport.")
115 ;(define-special-variable workspace-boundary-mode 'stop
116     ;"How to act when passing the first or last workspace, one of
117 ;`stop', `wrap-around' or `keep-going'")
119 ;(define-special-variable edge-flip-type 'viewport
120 ;    "Control what hitting the screen edge selects, workspace or viewport.")
122 ;(define-special-variable customize-command-classes '(viewport default)
123     ;"Also include commands of these classes the key bindings panel.
124 ;Add the `viewport' keyboard to make viewport commands show up.")
126 ;(bind-keys global-keymap "H-j" 'move-viewport-down)
127 ;(bind-keys global-keymap "H-k" 'move-viewport-up)
128 ;(bind-keys global-keymap "H-h" 'move-viewport-left)
129 ;(bind-keys global-keymap "H-l" 'move-viewport-right)
131 ;(bind-keys global-keymap "M-H-j" 'move-window-down)
132 ;(bind-keys global-keymap "M-H-k" 'move-window-up)
133 ;(bind-keys global-keymap "M-H-h" 'move-window-left)
134 ;(bind-keys global-keymap "M-H-l" 'move-window-right)
136 (bind-keys global-keymap "M-C-y" 'restart)
137 (system "lxpanel &")
139 ;(bind-keys global-keymap "H-p" '(system "sh ~/bin/chang-proxy.sh &"))
141 (bind-keys global-keymap "H-v" '(system "gvim -f &"))
143 ;(bind-keys global-keymap "H-q" '(system "/etc/acpi/hibernate.sh &"))
148 (defun wy-construct-arg-list (str sep)
149   "Construct a list from a string. Using sep as separetor."
150   (interactive)
151   (let* ((result nil)
152          (add-to-the-list
153           (lambda (x)
154             (setq result (cons x result)))))
155     (let loop ((s "")
156                (left str)
157                (ptr 0))
158          (setq nextchar (substring left 0 1))
159          (print s)
160          (catch 'exit
161            (cond ((and
162                    (string-match "\\s" nextchar)
163                    (> (length s) 0))
164                   (add-to-the-list s)
165                   (setq s ""))
166                  ((= (+ 1 ptr) (length str))
167                   (setq s (concat s nextchar))
168                   (if (> (length s) 0) (add-to-the-list s))
169                   (throw 'exit))
170                  (t
171                   (setq s (concat s nextchar))))
172            (loop s (substring left 1) (+ ptr 1))))
173     (reverse result)))
175 ;; startup programs
176 (defun wy-start-entry (prog-entry)
177   (interactive)
178   (let ((process (make-process standard-output))
179         (prog-entry-list (wy-construct-arg-list prog-entry "\\s")))
180     (apply start-process process (car prog-entry-list) (cdr prog-entry-list))))
182 (setq startup-programs
183       '("fspanel ")
185 (mapc wy-start-up startup-programs)
187 (defun wy-cleanup-on-exit ()
188   (mapc stop-process (active-processes)))
190 (add-hook 'after-initialization-hook 'wy-start-up)
191 (add-hook 'before-exit-hook 'wy-cleanup-on-exit)