XBINDKEYS: Place current tag last and last picked tag first.

This commit is contained in:
Tom Willemsen 2012-02-08 00:55:02 +01:00
parent 01a0c63067
commit c2942fa8cf

View file

@ -12,6 +12,9 @@
(define dzen-args (string-append " -fn '" font "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'")) (define dzen-args (string-append " -fn '" font "' -x 5 -y 5 -bg '#000000' -fg '#15abc3'"))
(define dzen-pipe '()) (define dzen-pipe '())
(define previous-tag '())
(define current-tag "default")
;;; Macros ;;; Macros
(define-macro (cmd command) (define-macro (cmd command)
`(lambda () `(lambda ()
@ -41,7 +44,11 @@
"TAGS=( $(herbstclient tag_status 0 | tr \":\\!.+#\" \" \") ); echo ${TAGS[@]}")) "TAGS=( $(herbstclient tag_status 0 | tr \":\\!.+#\" \" \") ); echo ${TAGS[@]}"))
(tags (string-split (read-line file) #\ ))) (tags (string-split (read-line file) #\ )))
(close-port file) (close-port file)
tags)) (set! tags (delete current-tag tags))
(set! tags (delete previous-tag tags))
(if (not (null? previous-tag))
(append `(,previous-tag) (append tags `(,current-tag)))
(append tags `(,current-tag)))))
(define (choose-tag prompt tags) (define (choose-tag prompt tags)
"Ask to choose a tag" "Ask to choose a tag"
@ -60,6 +67,8 @@
(begin (begin
(if (not (member tag tags)) (if (not (member tag tags))
(system (string-append "herbstclient add " tag))) (system (string-append "herbstclient add " tag)))
(set! previous-tag current-tag)
(set! current-tag tag)
(run-command (string-append "herbstclient use " tag)))) (run-command (string-append "herbstclient use " tag))))
(reset-main-binding))) (reset-main-binding)))