diff options
author | Tom Willemsen | 2012-02-06 23:47:14 +0100 |
---|---|---|
committer | Tom Willemsen | 2012-02-06 23:47:14 +0100 |
commit | 6e999ca93d7e114a1c1252160e92da6dfc8cbad8 (patch) | |
tree | 3f895273df3efa05d209c38c8944fe79f8c1c2ea /.xbindkeysrc.scm | |
parent | 13b9c2c80de0376666c60b3442bf5bb513e31384 (diff) | |
parent | f9eeef0571c908489c55d73b39efe6e7faebbdc5 (diff) | |
download | dotfiles-6e999ca93d7e114a1c1252160e92da6dfc8cbad8.tar.gz dotfiles-6e999ca93d7e114a1c1252160e92da6dfc8cbad8.zip |
Merge remote-tracking branch 'gitorious/master' into phoenix
Diffstat (limited to '.xbindkeysrc.scm')
-rw-r--r-- | .xbindkeysrc.scm | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/.xbindkeysrc.scm b/.xbindkeysrc.scm index e467941..bf5a77d 100644 --- a/.xbindkeysrc.scm +++ b/.xbindkeysrc.scm @@ -1,6 +1,10 @@ ;; -*- eval: (git-auto-commit-mode 1) -*- +(use-modules (ice-9 popen) + (ice-9 rdelim)) + ;;; Modkey (define modkey 'mod4) +(define dmenu-cmd "dmenu -b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'") ;;; Macros (define-macro (cmd command) @@ -16,6 +20,56 @@ (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 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* ((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 (define (main-binding) "First binding" @@ -41,10 +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")) @@ -53,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)) |