XBINDKEYS: Remove external scripts for tag handling
This commit is contained in:
parent
2f10eab467
commit
9f48c01515
4 changed files with 35 additions and 36 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
;;; Modkey
|
;;; Modkey
|
||||||
(define modkey 'mod4)
|
(define modkey 'mod4)
|
||||||
|
(define dmenu-cmd "dmenu -b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'")
|
||||||
|
|
||||||
;;; Macros
|
;;; Macros
|
||||||
(define-macro (cmd command)
|
(define-macro (cmd command)
|
||||||
|
@ -29,16 +30,44 @@
|
||||||
(define (get-tag tags pipe)
|
(define (get-tag tags pipe)
|
||||||
(read-line pipe))
|
(read-line pipe))
|
||||||
|
|
||||||
(define (choose-tag tags)
|
(define (choose-tag prompt tags)
|
||||||
(let* ((file (open-input-pipe (string-append "echo '" (string-join tags "\n") "' | dmenu")))
|
(let* ((file (open-input-pipe
|
||||||
|
(string-append "echo '" (string-join tags "\n")
|
||||||
|
"' | " dmenu-cmd " -p '" prompt ":'")))
|
||||||
(tag (read-line file)))
|
(tag (read-line file)))
|
||||||
(close-port file)
|
(close-port file)
|
||||||
tag))
|
tag))
|
||||||
|
|
||||||
(define (switch-tags)
|
(define (switch-tags)
|
||||||
"Switch to another tag"
|
"Switch to another tag"
|
||||||
(let ((tag (choose-tag (get-tags))))
|
(let* ((tags (get-tags))
|
||||||
(run-command (string-append "herbtsclient use " tag))
|
(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)))
|
(reset-main-binding)))
|
||||||
|
|
||||||
;;; Maps
|
;;; Maps
|
||||||
|
@ -66,11 +95,10 @@
|
||||||
"Second binding"
|
"Second binding"
|
||||||
(ungrab-all-keys)
|
(ungrab-all-keys)
|
||||||
(remove-all-keys)
|
(remove-all-keys)
|
||||||
;;(xbindkey-function '(b) (cmd "~/bin/switch_tags"))
|
|
||||||
(xbindkey-function '(b) switch-tags)
|
(xbindkey-function '(b) switch-tags)
|
||||||
(xbindkey-function `(,modkey c) (cmd "herbstclient quit"))
|
(xbindkey-function `(,modkey c) (cmd "herbstclient quit"))
|
||||||
(xbindkey-function `(,modkey r) (cmd "herbstclient reload"))
|
(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 '("0") (cmd "herbstclient remove"))
|
||||||
(xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5"))
|
(xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5"))
|
||||||
(xbindkey-function '("2") (cmd "herbstclient split vertical 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 '(shift f) (cmd "herbstclient fullscreen toggle"))
|
||||||
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle"))
|
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle"))
|
||||||
(xbindkey-function '(r) resize-map)
|
(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)
|
(xbindkey-function `(,modkey g) reset-main-binding)
|
||||||
(grab-all-keys))
|
(grab-all-keys))
|
||||||
|
|
||||||
|
|
10
bin/kill_tag
10
bin/kill_tag
|
@ -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
|
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/zsh
|
|
||||||
|
|
||||||
. $HOME/bin/hlwm_source
|
|
||||||
|
|
||||||
if [[ "${TAGS[@]}" != *" $FOO "* ]]; then
|
|
||||||
herbstclient add $FOO
|
|
||||||
fi
|
|
||||||
|
|
||||||
herbstclient move $FOO
|
|
|
@ -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
|
|
Loading…
Reference in a new issue