summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-02-07 20:17:53 +0100
committerGravatar Tom Willemsen2012-02-07 20:17:53 +0100
commita925132b75c083baf85426cdf9482de9dd809261 (patch)
treeeb2200903a87c5844b9cc2c16d48b9bc57dcaed1
parentdb354a5b6d501d49ff64cb2a2a368d3cb4132934 (diff)
parent5a87ca44b803f6d666593dac1b71c0c400b19f72 (diff)
downloaddotfiles-a925132b75c083baf85426cdf9482de9dd809261.tar.gz
dotfiles-a925132b75c083baf85426cdf9482de9dd809261.zip
Merge remote-tracking branch 'gitorious/master' into phoenix
-rw-r--r--.xbindkeysrc.scm39
1 files changed, 35 insertions, 4 deletions
diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm
index a58c09a..3bea5fe 100644
--- a/.xbindkeysrc.scm
+++ b/.xbindkeysrc.scm
@@ -2,9 +2,13 @@
(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 font "-misc-tamsyn-medium-r-normal-*-17-*-*-*-*-*-iso8859-*")
+(define dmenu-cmd "dmenu")
+(define dmenu-args
+ (string-append "-b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000' -fn '" font "'"))
+(define dzen-pipe '())
;;; Macros
(define-macro (cmd command)
@@ -15,6 +19,7 @@
;;; Functions
(define (reset-main-binding)
"reset first binding"
+ (close-gui-window)
(ungrab-all-keys)
(remove-all-keys)
(main-binding)
@@ -31,7 +36,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))
@@ -68,10 +73,32 @@
(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"
- (xbindkey `(,modkey shift "1") "dmenu_run")
+ (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)
@@ -91,6 +118,7 @@
(define (X-functions)
"Second binding"
+ (gui-print "S-x")
(ungrab-all-keys)
(remove-all-keys)
(xbindkey-function '(b) switch-tags)
@@ -110,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"))
@@ -127,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"))
@@ -140,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")