Add run-or-raise function for herbstluftwm
This commit is contained in:
parent
f43b572693
commit
f97c9d117c
2 changed files with 47 additions and 4 deletions
|
@ -65,9 +65,10 @@ hc keybind $Mod-Shift-k remove
|
||||||
|
|
||||||
# These are my most-used programs, having specific keybindings for
|
# These are my most-used programs, having specific keybindings for
|
||||||
# them is a big productivity boost.
|
# them is a big productivity boost.
|
||||||
hc keybind $Mod-Return spawn ${TERMINAL:-urxvt}
|
hc keybind $Mod-Return spawn urxvt
|
||||||
hc keybind $Mod-t spawn ${EDITOR:-emacs}
|
hc keybind $Mod-c spawn hlwm-run-or-raise URxvt urxvt
|
||||||
hc keybind $Mod-b spawn ${BROWSER:-conkeror}
|
hc keybind $Mod-t spawn hlwm-run-or-raise Emacs emacs
|
||||||
|
hc keybind $Mod-b spawn hlwm-run-or-raise Conkeror conkeror
|
||||||
|
|
||||||
# Since I use the colemak keyboard layout, hjkl doesn't make much
|
# Since I use the colemak keyboard layout, hjkl doesn't make much
|
||||||
# sense. I use neio instead since that is almost in the same place
|
# sense. I use neio instead since that is almost in the same place
|
||||||
|
@ -126,7 +127,6 @@ hc mousebind $Mod-Button3 resize
|
||||||
hc keybind $Mod-BackSpace cycle_monitor
|
hc keybind $Mod-BackSpace cycle_monitor
|
||||||
hc keybind $Mod-Tab cycle_all +1
|
hc keybind $Mod-Tab cycle_all +1
|
||||||
hc keybind $Mod-Shift-Tab cycle_all -1
|
hc keybind $Mod-Shift-Tab cycle_all -1
|
||||||
hc keybind $Mod-c cycle
|
|
||||||
|
|
||||||
# Use u because i is already used by by navigation commands.
|
# Use u because i is already used by by navigation commands.
|
||||||
hc keybind $Mod-u jumpto urgent
|
hc keybind $Mod-u jumpto urgent
|
||||||
|
|
43
herbstluftwm/usr/bin/hlwm-run-or-raise
Executable file
43
herbstluftwm/usr/bin/hlwm-run-or-raise
Executable file
|
@ -0,0 +1,43 @@
|
||||||
|
#!/usr/local/bin/scsh -s
|
||||||
|
!#
|
||||||
|
;; hrunorraise --- Raise a window or start a new process
|
||||||
|
;;
|
||||||
|
;; Tries to find a window ID for a window with a given class value. If
|
||||||
|
;; no such window can be found treat the rest of the command line as
|
||||||
|
;; the command to start.
|
||||||
|
;;
|
||||||
|
;; This script depends on both herbstluftwm and wmctrl.
|
||||||
|
|
||||||
|
(define (get-current-window-id)
|
||||||
|
(let* ((output (run/string (wmctrl -v -a ":ACTIVE:") (= 2 1)))
|
||||||
|
(re (rx "Using window: "
|
||||||
|
(submatch "0x" (+ hex-digit))
|
||||||
|
"\n"))
|
||||||
|
(match (regexp-search re output)))
|
||||||
|
(match:substring match 1)))
|
||||||
|
|
||||||
|
(define (pull-element-to-front elt collection)
|
||||||
|
(if (string= (car collection) elt)
|
||||||
|
collection
|
||||||
|
(pull-element-to-front elt (rotate collection))))
|
||||||
|
|
||||||
|
(define (rotate lst)
|
||||||
|
(append (cdr lst) (list (car lst))))
|
||||||
|
|
||||||
|
(define current-window-id
|
||||||
|
(get-current-window-id))
|
||||||
|
|
||||||
|
(define window-ids
|
||||||
|
(run/strings
|
||||||
|
(pipe (wmctrl -lx)
|
||||||
|
(awk "{ print $1, $3 }")
|
||||||
|
(grep ,(string-append "\\." (car command-line-arguments)))
|
||||||
|
(awk "{ print $1 }"))))
|
||||||
|
|
||||||
|
(if (not (null? window-ids))
|
||||||
|
(let ((next-window
|
||||||
|
(if (member current-window-id window-ids)
|
||||||
|
(cadr (pull-element-to-front current-window-id window-ids))
|
||||||
|
(car window-ids))))
|
||||||
|
(run (herbstclient jumpto ,next-window)))
|
||||||
|
(exec-epf (,@(cdr command-line-arguments))))
|
Loading…
Reference in a new issue