legacy-dotfiles/.xbindkeysrc.scm

157 lines
5.2 KiB
Scheme
Raw Normal View History

2012-01-30 12:26:17 +01:00
;; -*- eval: (git-auto-commit-mode 1) -*-
2012-02-06 21:51:01 +01:00
(use-modules (ice-9 popen)
(ice-9 rdelim))
2012-01-30 00:04:07 +01:00
;;; Modkey
(define modkey 'mod4)
(define dmenu-cmd "dmenu -b -nb '#000000' -nf '#15abc3' -sb '#e0c625' -sf '#000000'")
2012-01-30 00:04:07 +01:00
;;; Macros
(define-macro (cmd command)
`(lambda ()
(run-command ,command)
(reset-main-binding)))
;;; Functions
(define (reset-main-binding)
"reset first binding"
(ungrab-all-keys)
(remove-all-keys)
(main-binding)
(grab-all-keys))
2012-02-06 21:51:01 +01:00
(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 ":'")))
2012-02-06 21:51:01 +01:00
(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))))
2012-02-06 21:51:01 +01:00
(reset-main-binding)))
2012-01-30 00:04:07 +01:00
;;; Maps
(define (main-binding)
"First binding"
(xbindkey `(,modkey shift "1") "dmenu_run")
(xbindkey-function `(,modkey x) X-functions)
(xbindkey-function `(,modkey w) W-functions)
(xbindkey-function `(,modkey s) S-functions)
(xbindkey `(,modkey Return) "urxvt")
(xbindkey '(control alt l) "i3lock -c 000000")
(xbindkey '(XF86HomePage) "conkeror")
(xbindkey '(XF86Mail) "mutt")
(xbindkey '(XF86AudioPlay) "mpc toggle")
(xbindkey '(XF86AudioStop) "mpc stop")
(xbindkey '(XF86AudioMute) "amixer sset Master toggle")
(xbindkey '(XF86AudioLowerVolume) "mcp volume -5")
(xbindkey '(XF86AudioRaiseVolume) "mcp volume +5")
(xbindkey '(XF86AudioPrev) "mpc prev")
(xbindkey '(XF86AudioNext) "mpc next")
(xbindkey '(XF86Tools) "ncmpcpp")
(xbindkey-function `(,modkey g) reset-main-binding))
(define (X-functions)
"Second binding"
(ungrab-all-keys)
(remove-all-keys)
2012-02-06 21:51:01 +01:00
(xbindkey-function '(b) switch-tags)
2012-01-30 00:04:07 +01:00
(xbindkey-function `(,modkey c) (cmd "herbstclient quit"))
(xbindkey-function `(,modkey r) (cmd "herbstclient reload"))
(xbindkey-function '(k) kill-tag)
2012-01-30 00:04:07 +01:00
(xbindkey-function '("0") (cmd "herbstclient remove"))
(xbindkey-function '("3") (cmd "herbstclient split horizontal 0.5"))
(xbindkey-function '("2") (cmd "herbstclient split vertical 0.5"))
(xbindkey-function '(space) (cmd "herbstclient cycle_layout 1"))
(xbindkey-function '(f) (cmd "herbstclient floating toggle"))
(xbindkey-function '(shift f) (cmd "herbstclient fullscreen toggle"))
(xbindkey-function '(p) (cmd "herbstclient pseudotile toggle"))
(xbindkey-function '(r) resize-map)
(xbindkey-function '(m) move-to-tag)
2012-01-30 00:04:07 +01:00
(xbindkey-function `(,modkey g) reset-main-binding)
(grab-all-keys))
(define (W-functions)
(ungrab-all-keys)
(remove-all-keys)
(xbindkey-function '(k) (cmd "herbstclient close"))
(xbindkey-function '(w) (cmd "herbstclient cycle"))
(xbindkey-function '(o) (cmd "herbstclient cycle_all +1"))
(xbindkey-function '(b) (cmd "herbstclient focus left"))
(xbindkey-function '(n) (cmd "herbstclient focus down"))
(xbindkey-function '(p) (cmd "herbstclient focus up"))
(xbindkey-function '(f) (cmd "herbstclient focus right"))
(xbindkey-function '(shift b) (cmd "herbstclient shift left"))
(xbindkey-function '(shift n) (cmd "herbstclient shift down"))
(xbindkey-function '(shift p) (cmd "herbstclient shift up"))
(xbindkey-function '(shift f) (cmd "herbstclient shift right"))
(xbindkey-function `(,modkey g) reset-main-binding)
(grab-all-keys))
(define (S-functions)
(ungrab-all-keys)
(remove-all-keys)
(xbindkey-function '(o) (cmd "herbstclient cycle_monitor"))
(xbindkey-function `(,modkey g) reset-main-binding)
(grab-all-keys))
(define (P-functions)
(ungrab-all-keys)
(remove-all-keys)
(grab-all-keys))
(define (resize-map)
(ungrab-all-keys)
(remove-all-keys)
(xbindkey `(,modkey b) "herbstclient resize left +0.05")
(xbindkey `(,modkey n) "herbstclient rezise down +0.05")
(xbindkey `(,modkey p) "herbstclient resize up +0.05")
(xbindkey `(,modkey f) "herbstclient resize right +0.05")
(xbindkey-function '(Return) reset-main-binding)
(xbindkey-function `(,modkey g) reset-main-binding)
(grab-all-keys))
;;; Main
(main-binding)