From 2f10eab467b0f993b8f66bfeeffdf89f9949b406 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 6 Feb 2012 21:51:01 +0100 Subject: [PATCH] .xbindkeysrc.scm --- .xbindkeysrc.scm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index e467941..7e1e556 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -1,4 +1,7 @@ ;; -*- eval: (git-auto-commit-mode 1) -*- +(use-modules (ice-9 popen) + (ice-9 rdelim)) + ;;; Modkey (define modkey 'mod4) @@ -16,6 +19,28 @@ (main-binding) (grab-all-keys)) +(define (get-tags) + (let* ((file (open-input-pipe + "TAGS=( $(herbstclient tag_status 0 | tr \":\\!.+#\" \" \") ); echo ${TAGS[@]}")) + (tags (string-split (read-line file) #\ ))) + (close-port file) + tags)) + +(define (get-tag tags pipe) + (read-line pipe)) + +(define (choose-tag tags) + (let* ((file (open-input-pipe (string-append "echo '" (string-join tags "\n") "' | dmenu"))) + (tag (read-line file))) + (close-port file) + tag)) + +(define (switch-tags) + "Switch to another tag" + (let ((tag (choose-tag (get-tags)))) + (run-command (string-append "herbtsclient use " tag)) + (reset-main-binding))) + ;;; Maps (define (main-binding) "First binding" @@ -41,7 +66,8 @@ "Second binding" (ungrab-all-keys) (remove-all-keys) - (xbindkey-function '(b) (cmd "~/bin/switch_tags")) + ;;(xbindkey-function '(b) (cmd "~/bin/switch_tags")) + (xbindkey-function '(b) switch-tags) (xbindkey-function `(,modkey c) (cmd "herbstclient quit")) (xbindkey-function `(,modkey r) (cmd "herbstclient reload")) (xbindkey-function '(k) (cmd "~/bin/kill_tag"))