From 5aa3ec23c5037ac8ab0bd080123760c1b3df81b5 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 20:07:39 +0100 Subject: Cleanup --- .xbindkeysrc.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '.xbindkeysrc.scm') diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 3bea5fe..38d33a1 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -8,6 +8,8 @@ (define dmenu-cmd "dmenu") (define dmenu-args (string-append "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '" font "'")) +(define dzen-cmd "dzen2") +(define dzen-args (string-append " -fn '" font "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")) (define dzen-pipe '()) ;;; Macros @@ -26,6 +28,7 @@ (grab-all-keys)) (define (get-tags) + "Get a list of tags" (let* ((file (open-input-pipe "TAGS=( $(herbstclient tag_status 0 | tr \":\\!.+#\" \" \") ); echo ${TAGS[@]}")) (tags (string-split (read-line file) #\ ))) @@ -84,8 +87,8 @@ (define (gui-print text) (let ((width (+ (text-width font text) 10))) (set! dzen-pipe (open-output-pipe - (string-append "dzen2 -w " (number->string width) - " -fn '" font "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")))) + (string-append dzen-cmd " -w " (number->string width) + " " dzen-args)))) (display text dzen-pipe) (newline dzen-pipe)) -- cgit v1.2.3-54-g00ecf From 01a0c630672d869a7df0f4aae835433c7e68e939 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 22:10:35 +0100 Subject: XBINDKEYS: Macro-ify --- .xbindkeysrc.scm | 120 ++++++++++++++++++++++++------------------------------- 1 file changed, 53 insertions(+), 67 deletions(-) (limited to '.xbindkeysrc.scm') diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 38d33a1..9d87a2e 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -18,6 +18,14 @@ (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 (define (reset-main-binding) "reset first binding" @@ -85,6 +93,7 @@ -1))) (define (gui-print text) + (close-gui-window) (let ((width (+ (text-width font text) 10))) (set! dzen-pipe (open-output-pipe (string-append dzen-cmd " -w " (number->string width) @@ -102,9 +111,9 @@ (define (main-binding) "First binding" (xbindkey `(,modkey shift "1") (string-append "dmenu_run -p 'Run:' " dmenu-args)) - (xbindkey-function `(,modkey x) X-functions) - (xbindkey-function `(,modkey w) W-functions) - (xbindkey-function `(,modkey s) S-functions) + (xbindkey-function `(,modkey x) X-function-map) + (xbindkey-function `(,modkey w) W-function-map) + (xbindkey-function `(,modkey s) S-function-map) (xbindkey `(,modkey Return) "urxvt") (xbindkey '(control alt l) "i3lock -c 000000") (xbindkey '(XF86HomePage) "conkeror") @@ -119,70 +128,47 @@ (xbindkey '(XF86Tools) "ncmpcpp") (xbindkey-function `(,modkey g) reset-main-binding)) -(define (X-functions) - "Second binding" - (gui-print "S-x") - (ungrab-all-keys) - (remove-all-keys) - (xbindkey-function '(b) switch-tags) - (xbindkey-function `(,modkey c) (cmd "herbstclient quit")) - (xbindkey-function `(,modkey r) (cmd "herbstclient reload")) - (xbindkey-function '(k) kill-tag) - (xbindkey-function '("0") (cmd "herbstclient remove")) - (xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5")) - (xbindkey-function '("2") (cmd "herbstclient split vertical 0.5")) - (xbindkey-function '(space) (cmd "herbstclient cycle_layout 1")) - (xbindkey-function '(f) (cmd "herbstclient floating toggle")) - (xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle")) - (xbindkey-function '(p) (cmd "herbstclient pseudotile toggle")) - (xbindkey-function '(r) resize-map) - (xbindkey-function '(m) move-to-tag) - (xbindkey-function `(,modkey g) reset-main-binding) - (grab-all-keys)) - -(define (W-functions) - (gui-print "S-w") - (ungrab-all-keys) - (remove-all-keys) - (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")) - (xbindkey-function `(,modkey g) reset-main-binding) - (grab-all-keys)) - -(define (S-functions) - (gui-print "S-s") - (ungrab-all-keys) - (remove-all-keys) - (xbindkey-function '(o) (cmd "herbstclient cycle_monitor")) - (xbindkey-function `(,modkey g) reset-main-binding) - (grab-all-keys)) - -(define (P-functions) - (ungrab-all-keys) - (remove-all-keys) - - (grab-all-keys)) - -(define (resize-map) - (gui-print "Resizing") - (ungrab-all-keys) - (remove-all-keys) - (xbindkey `(,modkey b) "herbstclient resize left +0.05") - (xbindkey `(,modkey n) "herbstclient rezise 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) - (xbindkey-function `(,modkey g) reset-main-binding) - (grab-all-keys)) +(create-map X-function-map + (gui-print "S-x") + (xbindkey-function '(b) switch-tags) + (xbindkey-function `(,modkey c) (cmd "herbstclient quit")) + (xbindkey-function `(,modkey r) (cmd "herbstclient reload")) + (xbindkey-function '(k) kill-tag) + (xbindkey-function '("0") (cmd "herbstclient remove")) + (xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5")) + (xbindkey-function '("2") (cmd "herbstclient split vertical 0.5")) + (xbindkey-function '(space) (cmd "herbstclient cycle_layout 1")) + (xbindkey-function '(f) (cmd "herbstclient floating toggle")) + (xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle")) + (xbindkey-function '(p) (cmd "herbstclient pseudotile toggle")) + (xbindkey-function '(r) resize-map) + (xbindkey-function '(m) move-to-tag)) + +(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-binding) -- cgit v1.2.3-54-g00ecf From c2942fa8cf20b7c7fbefdb18b2c4fc9e1934fde8 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Wed, 8 Feb 2012 00:55:02 +0100 Subject: XBINDKEYS: Place current tag last and last picked tag first. --- .xbindkeysrc.scm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to '.xbindkeysrc.scm') diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 9d87a2e..5e7efca 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -12,6 +12,9 @@ (define dzen-args (string-append " -fn '" font "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")) (define dzen-pipe '()) +(define previous-tag '()) +(define current-tag "default") + ;;; Macros (define-macro (cmd command) `(lambda () @@ -41,7 +44,11 @@ "TAGS=( $(herbstclient tag_status 0 | tr \":\\!.+#\" \" \") ); echo ${TAGS[@]}")) (tags (string-split (read-line file) #\ ))) (close-port file) - tags)) + (set! tags (delete current-tag tags)) + (set! tags (delete previous-tag tags)) + (if (not (null? previous-tag)) + (append `(,previous-tag) (append tags `(,current-tag))) + (append tags `(,current-tag))))) (define (choose-tag prompt tags) "Ask to choose a tag" @@ -60,6 +67,8 @@ (begin (if (not (member tag tags)) (system (string-append "herbstclient add " tag))) + (set! previous-tag current-tag) + (set! current-tag tag) (run-command (string-append "herbstclient use " tag)))) (reset-main-binding))) -- cgit v1.2.3-54-g00ecf From 7728389084634358e817ea6b2e12c4c4067529b6 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 9 Feb 2012 09:09:50 +0100 Subject: .xbindkeysrc.scm --- .xbindkeysrc.scm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to '.xbindkeysrc.scm') diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 5e7efca..651479d 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -4,12 +4,19 @@ ;;; Variables (define modkey 'mod4) -(define font "-misc-tamsyn-medium-r-normal-*-17-*-*-*-*-*-iso8859-*") +(define dmenu-font + "-misc-tamsyn-medium-r-normal-*-14-*-*-*-*-*-iso8859-*") (define dmenu-cmd "dmenu") (define dmenu-args - (string-append "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '" font "'")) + (string-append + "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '" + dmenu-font "'")) +(define dzen-font + "-misc-tamsyn-medium-r-normal-*-17-*-*-*-*-*-iso8859-*") (define dzen-cmd "dzen2") -(define dzen-args (string-append " -fn '" font "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")) +(define dzen-args + (string-append " -fn '" dzen-font + "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")) (define dzen-pipe '()) (define previous-tag '()) -- cgit v1.2.3-54-g00ecf From e4f69ad9fdb9027070fe4fa3788b6c6dff073f04 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Thu, 9 Feb 2012 09:11:43 +0100 Subject: .xbindkeysrc.scm --- .xbindkeysrc.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to '.xbindkeysrc.scm') diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 651479d..9e17422 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -110,7 +110,7 @@ (define (gui-print text) (close-gui-window) - (let ((width (+ (text-width font text) 10))) + (let ((width (+ (text-width dzen-font text) 10))) (set! dzen-pipe (open-output-pipe (string-append dzen-cmd " -w " (number->string width) " " dzen-args)))) -- cgit v1.2.3-54-g00ecf