A global minor mode that integrates window movement within and outside of
emacs
.
The program uses i3-msg/swaymsg
to communicate with i3/sway
. It may not be
compatible with other window manager (although it is possible to adopt it to
other window manager that offers command line control).
Highlight:
- Allowing a key to be effective in both
emacs
andi3
.
xprop
if uses i3wm
or i3gaps
. jq
if uses sway
.
NOTE: to use i3-mode
, emacs
must be running in server-mode
.
use-package
andstraight.el
:(use-package i3-mode :straight (i3-mode :repo "junyi-hou/i3-mode" :host github :files ("i3-mode.el" "i3-call" "sway-call")) :init (i3-mode 1))
- manual installation:
copy
i3-mode.el
to yourload-path
andi3-call
sway-call
to yourPATH
, then(require 'i3-mode) (i3-mode 1)
Window managers intercept key events before it can reach emacs
. To allow key
events go to emacs
, I use a simple shell script i3-call~/~sway-call
. It
first detect whether the focused window is an emacs
window or not. If it is an
emacs
window, the key event is will be sent to emacs
.
This trick is useful if one wants to bind keys in both the window manager and
emacs
. For example, I use C-<hjkl>
to move window focus in emacs
. And
before this package, I use S-<hjkl>
to move focus in i3/sway
. This is
clearly suboptimal for me, as I use two sets of keys to perform essentially the
same function. i3-mode
allows me to fix this by binding C-<hjkl>
in both
i3/sway
and emacs
:
bindsym Control+l exec --no-startup-id i3-call focus right C-l
bindsym Control+h exec --no-startup-id i3-call focus left C-h
bindsym Control+k exec --no-startup-id i3-call focus up C-k
bindsym Control+j exec --no-startup-id i3-call focus down C-j
which instructs i3
to use C+<hjkl>
to move focus when the current
window is not emacs
. Otherwise, i3-call
will pass C-<hjkl>
to emacs
by
calling emacsclient -e (i3-integrated-key "C-k" "focus" "up")
.
MIT