summaryrefslogtreecommitdiffstats
path: root/.sawfish/rc
blob: cae788099a7a2188e7b16324a7583aa59adb0d61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
;; -*- mode: sawfish; -*-
(require 'rep.regexp)
(require 'sawfish.wm.commands.grow-pack)
(require 'sawfish.wm.commands.shrink-yank)
(require 'sawfish.wm.ext.match-window)
(require 'sawfish.wm.util.display-window)
(require 'sawfish.wm.util.prompt)

(define oni:window-packing-keymap (make-keymap))
(define oni:window-growing-keymap (make-keymap))
(define oni:window-shrinking-keymap (make-keymap))
(define oni:window-yanking-keymap (make-keymap))
(define oni:window-management-keymap (make-keymap))
(define oni:extended-keymap (make-keymap))

(defun oni:emacs-main-window-p (window)
  "Check wether or not WINDOW is Emacs' main window."
  (let ((name (window-name window)))
    (and (string-match "^emacs: " name)
         (not (string= "emacs: *Sauron*" name)))))

(defun oni:place-emacs-windows ()
  "Place Emacs' main, sauron and optionally speedbar windows the
way I like them."
  (let ((main-window (car (filter-windows oni:emacs-main-window-p)))
        (sauron-window (get-window-by-name "emacs: *Sauron*"))
        (speedbar-window (get-window-by-name "^Speedbar " #:regex t)))
    (move-window-to main-window 0 0)
    (move-window-to sauron-window 0 0)

    (set-window-type sauron-window 'transient)
    (pack-window-down sauron-window)
    (grow-window-right sauron-window)

    (when speedbar-window
      (move-window-to speedbar-window 0 0)
      (set-window-type speedbar-window 'transient)
      (yank-window-right main-window)
      (grow-window-down speedbar-window))

    (grow-window-down main-window)
    (grow-window-right main-window)))

(define-command 'oni:place-emacs-windows oni:place-emacs-windows)

(defun oni:run-or-raise (command class)
  "Either run COMMAND, or if a window with class CLASS is found,
raise it."
  (let ((w (get-window-by-class class)))
    (if w
        (display-window w)
      (run-shell-command command))))

(setq default-frame-style 'naquadah)
(setq prompt-color (cons (get-color "#eeeeec")
                         (get-color "#252e2b")))
(setq user-apps-menu
      '(("Emacs" (system "emacsclient -c &"))
        ("Terminal" (system "urxvt &"))))

(bind-keys oni:window-packing-keymap
           "p" 'pack-window-up
           "n" 'pack-window-down
           "b" 'pack-window-left
           "f" 'pack-window-right)

(bind-keys oni:window-growing-keymap
           "p" 'grow-window-up
           "n" 'grow-window-down
           "b" 'grow-window-left
           "f" 'grow-window-right)

(bind-keys oni:window-shrinking-keymap
           "p" 'shrink-window-up
           "n" 'shrink-window-down
           "b" 'shrink-window-left
           "f" 'shrink-window-right)

(bind-keys oni:window-yanking-keymap
           "p" 'yank-window-up
           "n" 'yank-window-down
           "b" 'yank-window-left
           "f" 'yank-window-right)

(bind-keys oni:window-management-keymap
           "M" 'maximize-window-toggle
           "p" oni:window-packing-keymap
           "g" oni:window-growing-keymap
           "s" oni:window-shrinking-keymap
           "y" oni:window-yanking-keymap
           "E" 'oni:place-emacs-windows)

(bind-keys global-keymap
           "XF86AudioPlay" '(run-shell-command "mpc toggle")
           "XF86AudioStop" '(run-shell-command "mpc stop")
           "XF86AudioMute" '(run-shell-command "amixer sset Master toggle")
           "XF86AudioLowerVolume" '(run-shell-command "mpc volume -5")
           "XF86AudioRaiseVolume" '(run-shell-command "mpc volume +5")
           "XF86AudioPrev" '(run-shell-command "mpc prev")
           "XF86AudioNext" '(run-shell-command "mpc next"))

(bind-keys oni:extended-keymap
           "w" oni:window-management-keymap)

;; (ungrab-keymap global-keymap)
(bind-keys global-keymap
           "Super-!" '(run-shell-command (prompt-for-string "Run: "))
           "C-M-l" '(run-shell-command "i3lock -c \"#000000\"")
           "Super-e" '(oni:run-or-raise (getenv "EDITOR") "Emacs")
           "Super-E" '(run-shell-command (getenv "EDITOR"))
           "Super-w" '(run-shell-command (getenv "BROWSER"))
           "Super-c" '(run-shell-command "urxvt")
           "Super-TAB" 'cycle-windows
           "Super-x" oni:extended-keymap
           "Super-f" 'pack-window-right
           "Super-b" 'pack-window-left
           "Super-n" 'pack-window-down
           "Super-p" 'pack-window-up
           "Menu" 'popup-root-menu
           "Super-M" 'maximize-window-toggle)
;; (grab-keymap global-keymap)

(add-window-matcher '((WM_CLASS . "^Firefox/Navigator$"))
                    '((position . north-east)))
(add-window-matcher '((WM_CLASS . "^Conkeror/Navigator$"))
                    '((position . north-east)))