summaryrefslogtreecommitdiffstats
path: root/.xbindkeysrc.scm
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-02-07 18:29:46 +0100
committerGravatar Tom Willemsen2012-02-07 18:29:46 +0100
commit5a87ca44b803f6d666593dac1b71c0c400b19f72 (patch)
treefc19f398c5ceb21faa67bfc46ece69fab7dcf958 /.xbindkeysrc.scm
parent94666fab5fcc917d5c563577330c1bb82ea0295d (diff)
downloaddotfiles-5a87ca44b803f6d666593dac1b71c0c400b19f72.tar.gz
dotfiles-5a87ca44b803f6d666593dac1b71c0c400b19f72.zip
XBINDKEYS: Show which key combo is in progress
Diffstat (limited to '.xbindkeysrc.scm')
-rw-r--r--.xbindkeysrc.scm37
1 files 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")