From 9f48c01515dbe6b88e6c847f62bbc7bbcc9b08b0 Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Mon, 6 Feb 2012 22:25:18 +0100 Subject: XBINDKEYS: Remove external scripts for tag handling --- .xbindkeysrc.scm | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) (limited to '.xbindkeysrc.scm') diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index 7e1e556..bf5a77d 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -4,6 +4,7 @@ ;;; Modkey (define modkey 'mod4) +(define dmenu-cmd "dmenu -b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") ;;; Macros (define-macro (cmd command) @@ -29,16 +30,44 @@ (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"))) +(define (choose-tag prompt tags) + (let* ((file (open-input-pipe + (string-append "echo '" (string-join tags "\n") + "' | " dmenu-cmd " -p '" prompt ":'"))) (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)) + (let* ((tags (get-tags)) + (tag (choose-tag "Switch to tag" tags))) + (if (string? tag) + (begin + (if (not (member tag tags)) + (run-command (string-append "herbstclient add " tag))) + (run-command (string-append "herbstclient use " tag)))) + (reset-main-binding))) + +(define (kill-tag) + "Kill a selected tag" + (let* ((tags (get-tags)) + (tag (choose-tag "Kill tag" tags))) + (if (string? tag) + (begin + (if (member tag tags) + (run-command (string-append "herbstclient merge_tag " tag))))) + (reset-main-binding))) + +(define (move-to-tag) + "Move selected window to another tag" + (let* ((tags (get-tags)) + (tag (choose-tag "Move to tag" tags))) + (if (string? tag) + (begin + (if (not (member tag tags)) + (run-command (string-append "herbstclient add " tag))) + (run-command (string-append "herbstclient move " tag)))) (reset-main-binding))) ;;; Maps @@ -66,11 +95,10 @@ "Second binding" (ungrab-all-keys) (remove-all-keys) - ;;(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")) + (xbindkey-function '(k) kill-tag) (xbindkey-function '("0") (cmd "herbstclient remove")) (xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5")) (xbindkey-function '("2") (cmd "herbstclient split vertical 0.5")) @@ -79,7 +107,7 @@ (xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle")) (xbindkey-function '(p) (cmd "herbstclient pseudotile toggle")) (xbindkey-function '(r) resize-map) - (xbindkey-function '(m) (cmd "~/bin/move_to_tag")) + (xbindkey-function '(m) move-to-tag) (xbindkey-function `(,modkey g) reset-main-binding) (grab-all-keys)) -- cgit v1.2.3-54-g00ecf