XBINDKEYS: Remove external scripts for tag handling

This commit is contained in:
Tom Willemsen 2012-02-06 22:25:18 +01:00
parent 2f10eab467
commit 9f48c01515
4 changed files with 35 additions and 36 deletions

View file

@ -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))

View file

@ -1,10 +0,0 @@
#!/bin/zsh
TAGS=( $(herbstclient tag_status 0 | tr ":\!.+#" " ") )
FOO=$(for i in "${TAGS[@]}"; do echo $i; done | dmenu)
if [[ "${TAGS[@]}" == *"$FOO"* ]]; then
herbstclient merge_tag $FOO
else
notify-send "Unknown tag: $FOO"
fi

View file

@ -1,9 +0,0 @@
#!/bin/zsh
. $HOME/bin/hlwm_source
if [[ "${TAGS[@]}" != *" $FOO "* ]]; then
herbstclient add $FOO
fi
herbstclient move $FOO

View file

@ -1,10 +0,0 @@
#!/bin/zsh
TAGS=( $(herbstclient tag_status 0 | tr ":\!.+#" " ") )
FOO=$(for i in "${TAGS[@]}"; do echo $i; done | dmenu)
if [[ "${TAGS[@]}" != *"$FOO"* ]]; then
herbstclient add $FOO
fi
herbstclient use $FOO