From 724ce012d4e7a59a7b02e5f981d80d3b81b0d228 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 11:07:38 +0100 Subject: [PATCH 1/7] .xbindkeysrc.scm --- .xbindkeysrc.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index a58c09a..ab52f00 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -2,9 +2,10 @@ (use-modules (ice-9 popen) (ice-9 rdelim)) -;;; Modkey +;;; Variables (define modkey 'mod4) -(define dmenu-cmd "dmenu -b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") +(define dmenu-cmd "dmenu") +(define dmenu-args "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") ;;; Macros (define-macro (cmd command) @@ -31,7 +32,7 @@ "Ask to choose a tag" (let* ((file (open-input-pipe (string-append "echo '" (string-join tags "\n") - "' | " dmenu-cmd " -p '" prompt ":'"))) + "' | " dmenu-cmd " " dmenu-args " -p '" prompt ":'"))) (tag (read-line file))) (close-port file) tag)) @@ -71,7 +72,7 @@ ;;; Maps (define (main-binding) "First binding" - (xbindkey `(,modkey shift "1") "dmenu_run") + (xbindkey `(,modkey shift "1") (string-append "dmenu_run " dmenu-args)) (xbindkey-function `(,modkey x) X-functions) (xbindkey-function `(,modkey w) W-functions) (xbindkey-function `(,modkey s) S-functions) From e34944838332e9d09936c4bf864ee9678519d2a8 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 11:08:33 +0100 Subject: [PATCH 2/7] .xbindkeysrc.scm --- .xbindkeysrc.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index ab52f00..ddd5505 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -72,7 +72,7 @@ ;;; Maps (define (main-binding) "First binding" - (xbindkey `(,modkey shift "1") (string-append "dmenu_run " dmenu-args)) + (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) From 049d7a595532844b2ab828bbb1ee2b13a4ff7556 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 11:08:54 +0100 Subject: [PATCH 3/7] .xbindkeysrc.scm --- .xbindkeysrc.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index ddd5505..7bc300a 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -72,7 +72,7 @@ ;;; Maps (define (main-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 w) W-functions) (xbindkey-function `(,modkey s) S-functions) From a09f13e0fd5a32b6da9e388bdbadabcd03cd3680 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 17:32:50 +0100 Subject: [PATCH 4/7] .xbindkeysrc.scm --- .xbindkeysrc.scm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 7bc300a..067aaa4 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -6,6 +6,7 @@ (define modkey 'mod4) (define dmenu-cmd "dmenu") (define dmenu-args "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") +(define dzen-pipe nil) ;;; Macros (define-macro (cmd command) @@ -39,6 +40,8 @@ (define (switch-tags) "Switch to another tag" + (close-pipe dzen-pipe) + (set! dzen-pipe nil) (let* ((tags (get-tags)) (tag (choose-tag "Switch to tag" tags))) (if (string? tag) @@ -92,6 +95,8 @@ (define (X-functions) "Second binding" + (set! dzen-pipe (open-output-pipe "dzen2")) + (display "S-x" dzen-pipe) (ungrab-all-keys) (remove-all-keys) (xbindkey-function '(b) switch-tags) From 09c67a2b70eeb841d7d4fc736dd7c48a0f45d35b Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 17:33:31 +0100 Subject: [PATCH 5/7] .xbindkeysrc.scm --- .xbindkeysrc.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 067aaa4..e78be50 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -6,7 +6,7 @@ (define modkey 'mod4) (define dmenu-cmd "dmenu") (define dmenu-args "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") -(define dzen-pipe nil) +(define dzen-pipe ()) ;;; Macros (define-macro (cmd command) @@ -41,7 +41,7 @@ (define (switch-tags) "Switch to another tag" (close-pipe dzen-pipe) - (set! dzen-pipe nil) + (set! dzen-pipe ()) (let* ((tags (get-tags)) (tag (choose-tag "Switch to tag" tags))) (if (string? tag) From 94666fab5fcc917d5c563577330c1bb82ea0295d Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 17:33:46 +0100 Subject: [PATCH 6/7] .xbindkeysrc.scm --- .xbindkeysrc.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index e78be50..b8377a0 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -6,7 +6,7 @@ (define modkey 'mod4) (define dmenu-cmd "dmenu") (define dmenu-args "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") -(define dzen-pipe ()) +(define dzen-pipe 0) ;;; Macros (define-macro (cmd command) @@ -41,7 +41,7 @@ (define (switch-tags) "Switch to another tag" (close-pipe dzen-pipe) - (set! dzen-pipe ()) + (set! dzen-pipe 0) (let* ((tags (get-tags)) (tag (choose-tag "Switch to tag" tags))) (if (string? tag) From 5a87ca44b803f6d666593dac1b71c0c400b19f72 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Tue, 7 Feb 2012 18:29:46 +0100 Subject: [PATCH 7/7] XBINDKEYS: Show which key combo is in progress --- .xbindkeysrc.scm | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index b8377a0..3bea5fe 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -4,9 +4,11 @@ ;;; Variables (define modkey 'mod4) +(define font "-misc-tamsyn-medium-r-normal-*-17-*-*-*-*-*-iso8859-*") (define dmenu-cmd "dmenu") -(define dmenu-args "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") -(define dzen-pipe 0) +(define dmenu-args + (string-append "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '" font "'")) +(define dzen-pipe '()) ;;; Macros (define-macro (cmd command) @@ -17,6 +19,7 @@ ;;; Functions (define (reset-main-binding) "reset first binding" + (close-gui-window) (ungrab-all-keys) (remove-all-keys) (main-binding) @@ -40,8 +43,6 @@ (define (switch-tags) "Switch to another tag" - (close-pipe dzen-pipe) - (set! dzen-pipe 0) (let* ((tags (get-tags)) (tag (choose-tag "Switch to tag" tags))) (if (string? tag) @@ -72,6 +73,28 @@ (run-command (string-append "herbstclient move " tag)))) (reset-main-binding))) +(define (text-width font text) + (let* ((pipe (open-input-pipe (string-append "textwidth '" font "' '" text "'"))) + (width (read-line pipe))) + (close-port pipe) + (if (string? width) + (string->number width) + -1))) + +(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'")))) + (display text dzen-pipe) + (newline dzen-pipe)) + +(define (close-gui-window) + (if (and (not (null? dzen-pipe)) + (not (port-closed? dzen-pipe))) + (close-pipe dzen-pipe) + (set! dzen-pipe '()))) + ;;; Maps (define (main-binding) "First binding" @@ -95,8 +118,7 @@ (define (X-functions) "Second binding" - (set! dzen-pipe (open-output-pipe "dzen2")) - (display "S-x" dzen-pipe) + (gui-print "S-x") (ungrab-all-keys) (remove-all-keys) (xbindkey-function '(b) switch-tags) @@ -116,6 +138,7 @@ (grab-all-keys)) (define (W-functions) + (gui-print "S-w") (ungrab-all-keys) (remove-all-keys) (xbindkey-function '(k) (cmd "herbstclient close")) @@ -133,6 +156,7 @@ (grab-all-keys)) (define (S-functions) + (gui-print "S-s") (ungrab-all-keys) (remove-all-keys) (xbindkey-function '(o) (cmd "herbstclient cycle_monitor")) @@ -146,6 +170,7 @@ (grab-all-keys)) (define (resize-map) + (gui-print "Resizing") (ungrab-all-keys) (remove-all-keys) (xbindkey `(,modkey b) "herbstclient resize left +0.05")