legacy-dotfiles/.sawfish/rc

159 lines
5.6 KiB
Text
Raw Normal View History

2012-11-19 23:23:22 +01:00
;; -*- mode: sawfish; -*-
(require 'rep.regexp)
(require 'sawfish.wm.commands.grow-pack)
(require 'sawfish.wm.commands.shrink-yank)
2012-11-27 11:13:52 +01:00
(require 'sawfish.wm.commands.x-cycle)
2012-11-19 23:23:22 +01:00
(require 'sawfish.wm.ext.match-window)
(require 'sawfish.wm.util.display-window)
(require 'sawfish.wm.util.prompt)
2012-11-20 01:13:19 +01:00
(require 'sawfish.wm.util.window-order)
2012-11-19 23:23:22 +01:00
(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)
2012-11-20 01:13:19 +01:00
(defun oni:run-or-raise (command #!key id name class role)
2012-11-19 23:23:22 +01:00
"Either run COMMAND, or if a window with class CLASS is found,
raise it."
2012-11-20 01:13:19 +01:00
(let* ((windows (filter
(lambda (x)
(and (or (not id) (equal (window-id x) id))
(or (not name (equal (window-name x) name)))
(or (not class) (equal (window-class x) class))
(or (not role) (equal (window-role x) role))))
(window-order)))
(first (car windows))
(w (if (equal first (input-focus)) (last windows) first)))
(if w (display-window w)
2012-11-20 02:12:42 +01:00
(call-command `(run-shell-command ,command)))))
2012-11-19 23:23:22 +01:00
2012-11-28 10:15:12 +01:00
(setq custom-show-symbols t)
2012-11-19 23:23:22 +01:00
(setq default-frame-style 'naquadah)
2012-11-28 10:15:12 +01:00
(setq default-font (get-font-typed "Xft" "Monaco-10"))
2012-11-27 11:13:52 +01:00
(setq grow-is-maximize nil)
2012-11-19 23:23:22 +01:00
(setq prompt-color (cons (get-color "#eeeeec")
2012-11-20 01:13:19 +01:00
(get-color "#111113")))
2012-10-11 21:33:07 +02:00
(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
2012-11-19 23:23:22 +01:00
"y" oni:window-yanking-keymap
"E" 'oni:place-emacs-windows)
2012-10-11 21:33:07 +02:00
(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
2012-11-20 18:54:03 +01:00
"w" oni:window-management-keymap
"Super-b" 'popup-window-list-menu)
2012-10-11 21:33:07 +02:00
;; (ungrab-keymap global-keymap)
2012-11-20 01:13:19 +01:00
(bind-keys
global-keymap
"C-M-l" '(run-shell-command "i3lock -c \"#000000\"")
2012-11-27 11:13:52 +01:00
"C-Super-B" 'shrink-window-left
"C-Super-F" 'shrink-window-right
"C-Super-N" 'shrink-window-down
"C-Super-P" 'shrink-window-up
"C-Super-TAB" 'cycle-class
"C-Super-`" 'popup-window-menu
"C-Super-b" 'grow-window-left
"C-Super-f" 'grow-window-right
"C-Super-n" 'grow-window-down
"C-Super-p" 'grow-window-up
"Menu" 'popup-root-menu
"Super-!" '(run-shell-command (prompt-for-string "Run: "))
"Super-:" 'call-command
"Super-B" 'yank-window-left
"Super-C" '(run-shell-command "urxvt")
2012-11-20 01:13:19 +01:00
"Super-E" '(run-shell-command (getenv "EDITOR"))
2012-11-27 11:13:52 +01:00
"Super-F" 'yank-window-right
"Super-M" 'maximize-window-toggle
"Super-N" 'yank-window-down
"Super-P" 'yank-window-up
"Super-TAB" 'cycle-windows
2012-11-20 01:13:19 +01:00
"Super-W" '(run-shell-command (getenv "BROWSER"))
2012-11-27 11:13:52 +01:00
"Super-`" 'popup-root-menu
"Super-b" 'pack-window-left
2012-11-20 01:13:19 +01:00
"Super-c" '(oni:run-or-raise "urxvt" #:class "URxvt")
2012-11-27 11:13:52 +01:00
"Super-e" '(oni:run-or-raise (getenv "EDITOR") #:class "Emacs")
2012-11-20 01:13:19 +01:00
"Super-f" 'pack-window-right
"Super-n" 'pack-window-down
"Super-p" 'pack-window-up
2012-11-27 11:13:52 +01:00
"Super-w" '(oni:run-or-raise (getenv "BROWSER") #:class "Conkeror")
"Super-x" oni:extended-keymap
)
2012-10-11 21:33:07 +02:00
;; (grab-keymap global-keymap)
2012-11-20 18:54:03 +01:00
(add-window-matcher '((WM_CLASS . "^(Firefox|Conkeror)/Navigator$"))
'((position . north-east)
(maximized . all)))