From e6c5065b5bcb1a52196eb3c3892b91c1b3da98fd Mon Sep 17 00:00:00 2001 From: William Carroll Date: Sat, 6 Oct 2018 17:12:04 -0400 Subject: Integrate i3 and Emacs Super shared KBDs between i3wm and Emacs for: - focusing windows (i.e. M-{h,j,k,l}) - deleting windows (i.e. M-q) More support may be needed, but this is good DWIM behavior for now. --- configs/linux/misc/.config/i3/i3-navigate-emacs | 41 +++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 configs/linux/misc/.config/i3/i3-navigate-emacs (limited to 'configs/linux/misc/.config/i3/i3-navigate-emacs') diff --git a/configs/linux/misc/.config/i3/i3-navigate-emacs b/configs/linux/misc/.config/i3/i3-navigate-emacs new file mode 100755 index 000000000000..f973c6667f74 --- /dev/null +++ b/configs/linux/misc/.config/i3/i3-navigate-emacs @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Heavily inspired by this blog post: +# https://bl.ocks.org/mijoharas/b9d09daed9654ca8d0d081015209ecd0 + +get_focused_window() { + i3-msg -t get_tree | jq -r ".. | select(.focused? == true).window_properties.class" +} + +perform_close() { + if [ "$(get_focused_window)" = "Emacs" ]; then + emacsclient -e "(delete-window)" + else + i3-msg kill + fi +} + +perform_move() { + if [ "$(get_focused_window)" = "Emacs" ]; then + emacsclient -e "(evil-window-$1 1)" + result=$? + if [ $result -ne 0 ]; then + i3-msg focus "$1" + fi + else + i3-msg focus "$1" + fi +} + +case "$1" in + left) ;& + right) ;& + up) ;& + down) + perform_move "$1" + ;; + quit) + perform_close + ;; + *) echo "command not found" ;; +esac -- cgit 1.4.1