XBINDKEYS: Macro-ify
This commit is contained in:
parent
5aa3ec23c5
commit
01a0c63067
1 changed files with 50 additions and 64 deletions
|
@ -18,6 +18,14 @@
|
||||||
(run-command ,command)
|
(run-command ,command)
|
||||||
(reset-main-binding)))
|
(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)
|
(define (reset-main-binding)
|
||||||
"reset first binding"
|
"reset first binding"
|
||||||
|
@ -85,6 +93,7 @@
|
||||||
-1)))
|
-1)))
|
||||||
|
|
||||||
(define (gui-print text)
|
(define (gui-print text)
|
||||||
|
(close-gui-window)
|
||||||
(let ((width (+ (text-width font text) 10)))
|
(let ((width (+ (text-width font text) 10)))
|
||||||
(set! dzen-pipe (open-output-pipe
|
(set! dzen-pipe (open-output-pipe
|
||||||
(string-append dzen-cmd " -w " (number->string width)
|
(string-append dzen-cmd " -w " (number->string width)
|
||||||
|
@ -102,9 +111,9 @@
|
||||||
(define (main-binding)
|
(define (main-binding)
|
||||||
"First binding"
|
"First binding"
|
||||||
(xbindkey `(,modkey shift "1") (string-append "dmenu_run -p 'Run:' " dmenu-args))
|
(xbindkey `(,modkey shift "1") (string-append "dmenu_run -p 'Run:' " dmenu-args))
|
||||||
(xbindkey-function `(,modkey x) X-functions)
|
(xbindkey-function `(,modkey x) X-function-map)
|
||||||
(xbindkey-function `(,modkey w) W-functions)
|
(xbindkey-function `(,modkey w) W-function-map)
|
||||||
(xbindkey-function `(,modkey s) S-functions)
|
(xbindkey-function `(,modkey s) S-function-map)
|
||||||
(xbindkey `(,modkey Return) "urxvt")
|
(xbindkey `(,modkey Return) "urxvt")
|
||||||
(xbindkey '(control alt l) "i3lock -c 000000")
|
(xbindkey '(control alt l) "i3lock -c 000000")
|
||||||
(xbindkey '(XF86HomePage) "conkeror")
|
(xbindkey '(XF86HomePage) "conkeror")
|
||||||
|
@ -119,11 +128,8 @@
|
||||||
(xbindkey '(XF86Tools) "ncmpcpp")
|
(xbindkey '(XF86Tools) "ncmpcpp")
|
||||||
(xbindkey-function `(,modkey g) reset-main-binding))
|
(xbindkey-function `(,modkey g) reset-main-binding))
|
||||||
|
|
||||||
(define (X-functions)
|
(create-map X-function-map
|
||||||
"Second binding"
|
|
||||||
(gui-print "S-x")
|
(gui-print "S-x")
|
||||||
(ungrab-all-keys)
|
|
||||||
(remove-all-keys)
|
|
||||||
(xbindkey-function '(b) switch-tags)
|
(xbindkey-function '(b) switch-tags)
|
||||||
(xbindkey-function `(,modkey c) (cmd "herbstclient quit"))
|
(xbindkey-function `(,modkey c) (cmd "herbstclient quit"))
|
||||||
(xbindkey-function `(,modkey r) (cmd "herbstclient reload"))
|
(xbindkey-function `(,modkey r) (cmd "herbstclient reload"))
|
||||||
|
@ -136,14 +142,10 @@
|
||||||
(xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle"))
|
(xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle"))
|
||||||
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle"))
|
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle"))
|
||||||
(xbindkey-function '(r) resize-map)
|
(xbindkey-function '(r) resize-map)
|
||||||
(xbindkey-function '(m) move-to-tag)
|
(xbindkey-function '(m) move-to-tag))
|
||||||
(xbindkey-function `(,modkey g) reset-main-binding)
|
|
||||||
(grab-all-keys))
|
|
||||||
|
|
||||||
(define (W-functions)
|
(create-map W-function-map
|
||||||
(gui-print "S-w")
|
(gui-print "S-w")
|
||||||
(ungrab-all-keys)
|
|
||||||
(remove-all-keys)
|
|
||||||
(xbindkey-function '(k) (cmd "herbstclient close"))
|
(xbindkey-function '(k) (cmd "herbstclient close"))
|
||||||
(xbindkey-function '(w) (cmd "herbstclient cycle"))
|
(xbindkey-function '(w) (cmd "herbstclient cycle"))
|
||||||
(xbindkey-function '(o) (cmd "herbstclient cycle_all +1"))
|
(xbindkey-function '(o) (cmd "herbstclient cycle_all +1"))
|
||||||
|
@ -154,35 +156,19 @@
|
||||||
(xbindkey-function '(shift b) (cmd "herbstclient shift left"))
|
(xbindkey-function '(shift b) (cmd "herbstclient shift left"))
|
||||||
(xbindkey-function '(shift n) (cmd "herbstclient shift down"))
|
(xbindkey-function '(shift n) (cmd "herbstclient shift down"))
|
||||||
(xbindkey-function '(shift p) (cmd "herbstclient shift up"))
|
(xbindkey-function '(shift p) (cmd "herbstclient shift up"))
|
||||||
(xbindkey-function '(shift f) (cmd "herbstclient shift right"))
|
(xbindkey-function '(shift f) (cmd "herbstclient shift right")))
|
||||||
(xbindkey-function `(,modkey g) reset-main-binding)
|
|
||||||
(grab-all-keys))
|
|
||||||
|
|
||||||
(define (S-functions)
|
(create-map S-function-map
|
||||||
(gui-print "S-s")
|
(gui-print "S-s")
|
||||||
(ungrab-all-keys)
|
(xbindkey-function '(o) (cmd "herbstclient cycle_monitor")))
|
||||||
(remove-all-keys)
|
|
||||||
(xbindkey-function '(o) (cmd "herbstclient cycle_monitor"))
|
|
||||||
(xbindkey-function `(,modkey g) reset-main-binding)
|
|
||||||
(grab-all-keys))
|
|
||||||
|
|
||||||
(define (P-functions)
|
(create-map resize-map
|
||||||
(ungrab-all-keys)
|
|
||||||
(remove-all-keys)
|
|
||||||
|
|
||||||
(grab-all-keys))
|
|
||||||
|
|
||||||
(define (resize-map)
|
|
||||||
(gui-print "Resizing")
|
(gui-print "Resizing")
|
||||||
(ungrab-all-keys)
|
|
||||||
(remove-all-keys)
|
|
||||||
(xbindkey `(,modkey b) "herbstclient resize left +0.05")
|
(xbindkey `(,modkey b) "herbstclient resize left +0.05")
|
||||||
(xbindkey `(,modkey n) "herbstclient rezise down +0.05")
|
(xbindkey `(,modkey n) "herbstclient resize down +0.05")
|
||||||
(xbindkey `(,modkey p) "herbstclient resize up +0.05")
|
(xbindkey `(,modkey p) "herbstclient resize up +0.05")
|
||||||
(xbindkey `(,modkey f) "herbstclient resize right +0.05")
|
(xbindkey `(,modkey f) "herbstclient resize right +0.05")
|
||||||
(xbindkey-function '(Return) reset-main-binding)
|
(xbindkey-function '(Return) reset-main-binding))
|
||||||
(xbindkey-function `(,modkey g) reset-main-binding)
|
|
||||||
(grab-all-keys))
|
|
||||||
|
|
||||||
;;; Main
|
;;; Main
|
||||||
(main-binding)
|
(main-binding)
|
||||||
|
|
Loading…
Reference in a new issue