Skip to content

Instantly share code, notes, and snippets.

@aeghn
Created July 18, 2020 04:13
Show Gist options
  • Save aeghn/1ddf7941f9ed19135479e20a074651e2 to your computer and use it in GitHub Desktop.
Save aeghn/1ddf7941f9ed19135479e20a074651e2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author: Aeghn
# Jump between Emacs and i3wm
WM_CLASS_STRING=$(xprop -id $(xdotool getwindowfocus) WM_CLASS)
WM_CLASS_STRING=${WM_CLASS_STRING##* }
emacsclient=~/.local/bin/emacsclient
# get_side_window() {
# echo "(select-window (let ((window nil))
# (while (window-in-direction '${1} window)
# (setq window (window-in-direction '${1} window)))
# window))"
# }
case $1 in
i) [ "${WM_CLASS_STRING}" == '"Emacs"' ] &&\
$emacsclient -e "(windmove-left)" ||\
i3-msg 'focus left'
;;
o) [ "${WM_CLASS_STRING}" == '"Emacs"' ] &&\
$emacsclient -e "(windmove-right)" ||\
i3-msg 'focus right'
;;
p) [ "${WM_CLASS_STRING}" == '"Emacs"' ] &&\
$emacsclient -e "(windmove-up)" ||\
i3-msg 'focus up'
;;
n) [ "${WM_CLASS_STRING}" == '"Emacs"' ] &&\
$emacsclient -e "(windmove-down)" ||\
i3-msg 'focus down'
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment