Merge remote-tracking branch 'github/master' into phoenix

Conflicts:
	.xbindkeysrc.scm
This commit is contained in:
Tom Willemsen 2012-04-15 18:04:13 +00:00
commit 88a63ffaa3

View file

@ -1,51 +1,37 @@
;;;_ Import ;;;_ Import
(use-modules (ice-9 popen) (use-modules (ice-9 popen)
(ice-9 rdelim)) (ice-9 rdelim)
(srfi srfi-19))
;;;_ Variables ;;;_ Variables
(define browser (getenv "BROWSER"))
(define dmenu-cmd "dmenu")
(define dzen-cmd "dzen2")
(define dzen-pipe '())
(define editor (getenv "EDITOR"))
(define modkey 'mod4) (define modkey 'mod4)
(define prefix `(,modkey w))
(define terminal "urxvt")
(define date-format "~a ~d ~b ~Y ~H:~M")
(define previous-tag '())
(define current-tag "default")
(define dmenu-font (define dmenu-font
"-misc-tamsyn-medium-r-normal-*-14-*-*-*-*-*-iso8859-*") "-misc-tamsyn-medium-r-normal-*-14-*-*-*-*-*-iso8859-*")
(define dmenu-cmd "dmenu")
(define dmenu-args (define dmenu-args
(string-append (string-append
"-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '" "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '"
dmenu-font "'")) dmenu-font "'"))
(define dzen-font (define dzen-font
"-misc-tamsyn-medium-r-normal-*-17-*-*-*-*-*-iso8859-*") "-misc-tamsyn-medium-r-normal-*-17-*-*-*-*-*-iso8859-*")
(define dzen-cmd "dzen2")
(define dzen-args (define dzen-args
(string-append " -fn '" dzen-font (string-append " -fn '" dzen-font
"' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")) "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'"))
(define dzen-pipe '())
(define previous-tag '())
(define current-tag "default")
(define terminal "st")
;;;_ Macros
(define-macro (cmd command)
`(lambda ()
(run-command ,command)
(reset-main-binding)))
(define-macro (create-map name binding . more)
`(define (,name)
(ungrab-all-keys)
(remove-all-keys)
(begin ,binding . ,more)
(xbindkey-function `(,modkey g) reset-main-binding)
(grab-all-keys)))
;;;_ Functions ;;;_ Functions
(define (reset-main-binding)
"reset first binding"
(close-gui-window)
(ungrab-all-keys)
(remove-all-keys)
(main-binding)
(grab-all-keys))
(define (get-tags) (define (get-tags)
"Get a list of tags" "Get a list of tags"
(let* ((file (open-input-pipe (let* ((file (open-input-pipe
@ -82,20 +68,20 @@
(let* ((tags (get-tags)) (let* ((tags (get-tags))
(tag (choose-tag "Switch to tag" tags))) (tag (choose-tag "Switch to tag" tags)))
(switch-to-tag tag) (switch-to-tag tag)
(reset-main-binding))) (reset-first-binding)))
(define (switch-and-run) ;; (define (switch-and-run)
"Ask for a command to run, switch to a tag with that name and run ;; "Ask for a command to run, switch to a tag with that name and run
the command." ;; the command."
(let* ((file (open-input-pipe ;; (let* ((file (open-input-pipe
(string-append "dmenu_pick -p 'Run:' " dmenu-args))) ;; (string-append "dmenu_pick -p 'Run:' " dmenu-args)))
(prog (read-line file))) ;; (prog (read-line file)))
(close-port file) ;; (close-port file)
(if (string? prog) ;; (if (string? prog)
(begin ;; (begin
(switch-to-tag prog) ;; (switch-to-tag prog)
(run-command prog))) ;; (run-command prog)))
(reset-main-binding))) ;; (reset-first-binding)))
(define (kill-tag) (define (kill-tag)
"Kill a selected tag" "Kill a selected tag"
@ -105,7 +91,7 @@ the command."
(begin (begin
(if (member tag tags) (if (member tag tags)
(run-command (string-append "herbstclient merge_tag " tag))))) (run-command (string-append "herbstclient merge_tag " tag)))))
(reset-main-binding))) (reset-first-binding)))
(define (move-to-tag) (define (move-to-tag)
"Move selected window to another tag" "Move selected window to another tag"
@ -116,7 +102,7 @@ the command."
(if (not (member tag tags)) (if (not (member tag tags))
(system (string-append "herbstclient add " tag))) (system (string-append "herbstclient add " tag)))
(run-command (string-append "herbstclient move " tag)))) (run-command (string-append "herbstclient move " tag))))
(reset-main-binding))) (reset-first-binding)))
(define (text-width font text) (define (text-width font text)
(let* ((pipe (open-input-pipe (string-append "textwidth '" font "' '" text "'"))) (let* ((pipe (open-input-pipe (string-append "textwidth '" font "' '" text "'")))
@ -147,20 +133,69 @@ the command."
(define (revive-mouse) (define (revive-mouse)
(run-command "synclient TouchpadOff=0")) (run-command "synclient TouchpadOff=0"))
;;;_ Maps (define (notify msg)
(define (main-binding) (run-command (string-append "notify-send \"" msg "\"")))
(define (reset-first-binding)
"reset first binding"
(ungrab-all-keys)
(remove-all-keys)
(first-binding)
(grab-all-keys))
(define (run-terminal)
"Run the specified terminal program."
(run-command terminal)
(reset-first-binding))
(define (run-browser)
"Run the specified browser."
(run-command browser)
(reset-first-binding))
(define (run-editor)
"Run the specified terminal editor."
(run-command editor)
(reset-first-binding))
(define (banish)
"Banish the mouse cursor to the bottom-right corner of the screen."
(run-command "xte 'mousemove 4000 1100'")
(reset-first-binding))
(define (showtime)
"Show the time."
(notify (date->string (current-date) date-format))
(reset-first-binding))
(define (exec)
"Run a program."
(run-command (string-append "dmenu_run -p 'Run:' " dmenu-args))
(reset-first-binding))
(define (first-binding)
"First binding" "First binding"
(xbindkey `(,modkey shift "1") (string-append "dmenu_run -p 'Run:' " dmenu-args)) (xbindkey-function prefix second-binding)
(xbindkey `(,modkey "0") "herbstclient remove") (xbindkey '(control mod1 l) "i3lock -c 000000")
(xbindkey `(,modkey "2") "herbstclient split vertical 0.5") (xbindkey `(,modkey period) "herbstclient cycle_monitor 1")
(xbindkey `(,modkey "3") "herbstclient split horizontal 0.5") (xbindkey `(,modkey comma) "herbstclient cycle_monitor -1")
(xbindkey-function `(,modkey x) X-function-map) (xbindkey `(,modkey s) "herbstclient split vertical 0.5")
(xbindkey-function `(,modkey w) W-function-map) (xbindkey `(,modkey shift s) "herbstclient split horizontal 0.5")
(xbindkey-function `(,modkey s) S-function-map) (xbindkey `(,modkey q) "herbstclient remove")
(xbindkey `(,modkey Return) terminal) (xbindkey `(,modkey o) "herbstclient cycle_all")
(xbindkey '(control alt l) "i3lock -c 000000") (xbindkey `(,modkey control b) "herbstclient resize left +0.05")
(xbindkey '(XF86HomePage) "conkeror") (xbindkey `(,modkey control n) "herbstclient resize down +0.05")
(xbindkey '(XF86Mail) "mutt") (xbindkey `(,modkey control p) "herbstclient resize up +0.05")
(xbindkey `(,modkey control f) "herbstclient resize right +0.05")
(xbindkey `(,modkey b) "herbstclient focus left")
(xbindkey `(,modkey n) "herbstclient focus down")
(xbindkey `(,modkey p) "herbstclient focus up")
(xbindkey `(,modkey f) "herbstclient focus right")
(xbindkey `(,modkey shift b) "herbstclient shift left")
(xbindkey `(,modkey shift n) "herbstclient shift down")
(xbindkey `(,modkey shift p) "herbstclient shift up")
(xbindkey `(,modkey shift f) "herbstclient shift right")
(xbindkey `(,modkey space) "herbstclient cycle_layout 1")
(xbindkey '(XF86AudioPlay) "mpc toggle") (xbindkey '(XF86AudioPlay) "mpc toggle")
(xbindkey '(XF86AudioStop) "mpc stop") (xbindkey '(XF86AudioStop) "mpc stop")
(xbindkey '(XF86AudioMute) "amixer sset Master toggle") (xbindkey '(XF86AudioMute) "amixer sset Master toggle")
@ -168,60 +203,28 @@ the command."
(xbindkey '(XF86AudioRaiseVolume) "mcp volume +5") (xbindkey '(XF86AudioRaiseVolume) "mcp volume +5")
(xbindkey '(XF86AudioPrev) "mpc prev") (xbindkey '(XF86AudioPrev) "mpc prev")
(xbindkey '(XF86AudioNext) "mpc next") (xbindkey '(XF86AudioNext) "mpc next")
(xbindkey '(XF86Tools) "ncmpcpp")
(xbindkey `(,modkey b) "herbstclient focus left")
(xbindkey `(,modkey n) "herbstclient focus down")
(xbindkey `(,modkey p) "herbstclient focus up")
(xbindkey `(,modkey f) "herbstclient focus right")
(xbindkey-function '(XF86TouchpadOff) kill-mouse) (xbindkey-function '(XF86TouchpadOff) kill-mouse)
(xbindkey-function '(XF86TouchpadOn) revive-mouse) (xbindkey-function '(XF86TouchpadOn) revive-mouse))
(xbindkey-function `(,modkey g) reset-main-binding)) (xbindkey `(,modkey k) "herbstclient close"))
(create-map X-function-map (define (second-binding)
(gui-print "S-x") "Second binding"
(xbindkey-function '(b) switch-tags) (ungrab-all-keys)
(xbindkey-function `(,modkey c) (cmd "herbstclient quit")) (remove-all-keys)
(xbindkey-function `(,modkey r) (cmd "herbstclient reload")) (xbindkey-function 'c run-terminal)
(xbindkey-function '(k) kill-tag) (xbindkey-function 'e run-editor)
(xbindkey-function '("0") (cmd "herbstclient remove")) (xbindkey-function 'w run-browser)
(xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5")) (xbindkey-function 'z banish)
(xbindkey-function '("2") (cmd "herbstclient split vertical 0.5")) (xbindkey-function 'a showtime)
(xbindkey-function '(space) (cmd "herbstclient cycle_layout 1")) (xbindkey-function '(shift "1") exec)
(xbindkey-function '(f) (cmd "herbstclient floating toggle")) (xbindkey-function '(control g) reset-first-binding)
(xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle")) (xbindkey-function '(b) switch-tags)
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle")) (xbindkey-function '(k) kill-tag)
(xbindkey-function '(r) resize-map) (xbindkey-function '(m) move-to-tag)
(xbindkey-function '(m) move-to-tag) (grab-all-keys))
(xbindkey-function `(,modkey f) switch-and-run))
(create-map W-function-map
(gui-print "S-w")
(xbindkey-function '(k) (cmd "herbstclient close"))
(xbindkey-function '(w) (cmd "herbstclient cycle"))
(xbindkey-function '(o) (cmd "herbstclient cycle_all +1"))
(xbindkey-function '(b) (cmd "herbstclient focus left"))
(xbindkey-function '(n) (cmd "herbstclient focus down"))
(xbindkey-function '(p) (cmd "herbstclient focus up"))
(xbindkey-function '(f) (cmd "herbstclient focus right"))
(xbindkey-function '(shift b) (cmd "herbstclient shift left"))
(xbindkey-function '(shift n) (cmd "herbstclient shift down"))
(xbindkey-function '(shift p) (cmd "herbstclient shift up"))
(xbindkey-function '(shift f) (cmd "herbstclient shift right")))
(create-map S-function-map
(gui-print "S-s")
(xbindkey-function '(o) (cmd "herbstclient cycle_monitor")))
(create-map resize-map
(gui-print "Resizing")
(xbindkey `(,modkey b) "herbstclient resize left +0.05")
(xbindkey `(,modkey n) "herbstclient resize down +0.05")
(xbindkey `(,modkey p) "herbstclient resize up +0.05")
(xbindkey `(,modkey f) "herbstclient resize right +0.05")
(xbindkey-function '(Return) reset-main-binding))
;;;_ Main ;;;_ Main
(main-binding) (first-binding)
;;;_ Local Variables ;;;_ Local Variables
;; Local Variables: ;; Local Variables: