summaryrefslogtreecommitdiffstats
path: root/.xbindkeysrc.scm
diff options
context:
space:
mode:
Diffstat (limited to '.xbindkeysrc.scm')
-rw-r--r--.xbindkeysrc.scm28
1 files changed, 27 insertions, 1 deletions
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"))