Mouse following the focused window?

u/ironj

put this in i3config, instead of standard movement keys.

bindsym $mod+h exec "~/.config/i3/move-cursor.sh focus left"
bindsym $mod+j exec "~/.config/i3/move-cursor.sh focus down"
bindsym $mod+k exec "~/.config/i3/move-cursor.sh focus up"
bindsym $mod+l exec "~/.config/i3/move-cursor.sh focus right"

put this in ~/.config/i3/move-cursor.sh

#!/bin/sh
eval i3-msg $*
HERE=\xdotool getwindowfocus` ULX=`xwininfo -id $HERE | grep " Absolute upper-left X:" | awk '{print $4}'` ULY=`xwininfo -id $HERE | grep " Absolute upper-left Y:" | awk '{print $4}'` if [ $ULX != "-1" -o $ULY != "-1" ]; then eval `xdotool getwindowgeometry --shell $HERE` NX=`expr $WIDTH / 2` NY=`expr $HEIGHT / 2` xdotool mousemove --window $WINDOW $NX $NY fi`

/r/i3wm Thread Parent