i3: Always move cursor to focused window

This commit is contained in:
Geoffrey Frogeye 2019-10-30 16:39:55 +01:00
parent 5258e016ef
commit 90ca29d35c
2 changed files with 78 additions and 66 deletions

View file

@ -80,10 +80,10 @@ focus_follows_mouse no
mouse_warping output
# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right
bindsym $mod+h focus left; exec ~/.config/i3/focus_windows
bindsym $mod+j focus down; exec ~/.config/i3/focus_windows
bindsym $mod+k focus up; exec ~/.config/i3/focus_windows
bindsym $mod+l focus right; exec ~/.config/i3/focus_windows
## alternatively, you can use the cursor keys:
#bindsym $mod+Left focus left
@ -92,10 +92,10 @@ bindsym $mod+l focus right
#bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right
bindsym $mod+Shift+h move left; exec ~/.config/i3/focus_windows
bindsym $mod+Shift+j move down; exec ~/.config/i3/focus_windows
bindsym $mod+Shift+k move up; exec ~/.config/i3/focus_windows
bindsym $mod+Shift+l move right; exec ~/.config/i3/focus_windows
## alternatively, you can use the cursor keys:
#bindsym $mod+Shift+Left move left
@ -105,34 +105,34 @@ bindsym $mod+Shift+l move right
# workspace back and forth (with/without active container)
workspace_auto_back_and_forth no
bindsym $mod+b workspace back_and_forth
bindsym $mod+Shift+b move container to workspace back_and_forth; workspace back_and_forth
bindsym $mod+b workspace back_and_forth; exec ~/.config/i3/focus_windows
bindsym $mod+Shift+b move container to workspace back_and_forth; workspace back_and_forth; exec ~/.config/i3/focus_windows
# split in horizontal orientation
bindsym $mod+g split h
bindsym $mod+g split h; exec ~/.config/i3/focus_windows
# split in vertical orientation
bindsym $mod+v split v
bindsym $mod+v split v; exec ~/.config/i3/focus_windows
# toggle fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle
bindsym $mod+f fullscreen toggle; exec ~/.config/i3/focus_windows
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split
bindsym $mod+s layout stacking; exec ~/.config/i3/focus_windows
bindsym $mod+w layout tabbed; exec ~/.config/i3/focus_windows
bindsym $mod+e layout toggle split; exec ~/.config/i3/focus_windows
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
bindsym $mod+Shift+space floating toggle; exec ~/.config/i3/focus_windows
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
bindsym $mod+space focus mode_toggle; exec ~/.config/i3/focus_windows
# focus the parent container
bindsym $mod+a focus parent
bindsym $mod+a focus parent; exec ~/.config/i3/focus_windows
# focus the child container
bindsym $mod+q focus child
bindsym $mod+q focus child; exec ~/.config/i3/focus_windows
# Workspace names
set $WS1 1
@ -159,22 +159,22 @@ workspace "$WS9" output eDP-1-1
workspace "$WS10" output HDMI-0
# switch to workspace
bindsym $mod+1 workspace $WS1
bindsym $mod+2 workspace $WS2
bindsym $mod+3 workspace $WS3
bindsym $mod+4 workspace $WS4
bindsym $mod+5 workspace $WS5
bindsym $mod+6 workspace $WS6
bindsym $mod+7 workspace $WS7
bindsym $mod+8 workspace $WS8
bindsym $mod+9 workspace $WS9
bindsym $mod+0 workspace $WS10
bindsym $mod+1 workspace $WS1; exec ~/.config/i3/focus_windows
bindsym $mod+2 workspace $WS2; exec ~/.config/i3/focus_windows
bindsym $mod+3 workspace $WS3; exec ~/.config/i3/focus_windows
bindsym $mod+4 workspace $WS4; exec ~/.config/i3/focus_windows
bindsym $mod+5 workspace $WS5; exec ~/.config/i3/focus_windows
bindsym $mod+6 workspace $WS6; exec ~/.config/i3/focus_windows
bindsym $mod+7 workspace $WS7; exec ~/.config/i3/focus_windows
bindsym $mod+8 workspace $WS8; exec ~/.config/i3/focus_windows
bindsym $mod+9 workspace $WS9; exec ~/.config/i3/focus_windows
bindsym $mod+0 workspace $WS10; exec ~/.config/i3/focus_windows
#navigate workspaces next / previous
bindsym $mod+Ctrl+h workspace prev_on_output
bindsym $mod+Ctrl+l workspace next_on_output
bindsym $mod+Ctrl+j workspace prev
bindsym $mod+Ctrl+k workspace next
bindsym $mod+Ctrl+h workspace prev_on_output; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+l workspace next_on_output; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+j workspace prev; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+k workspace next; exec ~/.config/i3/focus_windows
##navigate workspaces next / previous (arrow keys)
#bindsym $mod+Ctrl+Left workspace prev_on_output
@ -183,10 +183,10 @@ bindsym $mod+Ctrl+k workspace next
#bindsym $mod+Ctrl+Up workspace next
# Move to workspace next / previous with focused container
bindsym $mod+Ctrl+Shift+h move container to workspace prev_on_output; workspace prev_on_output
bindsym $mod+Ctrl+Shift+l move container to workspace next_on_output; workspace next_on_output
bindsym $mod+Ctrl+Shift+j move container to workspace prev; workspace prev
bindsym $mod+Ctrl+Shift+k move container to workspace next; workspace next
bindsym $mod+Ctrl+Shift+h move container to workspace prev_on_output; workspace prev_on_output; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+Shift+l move container to workspace next_on_output; workspace next_on_output; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+Shift+j move container to workspace prev; workspace prev; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+Shift+k move container to workspace next; workspace next; exec ~/.config/i3/focus_windows
## Move to workspace next / previous with focused container (arrow keys)
#bindsym $mod+Ctrl+Shift+Left move container to workspace prev_on_output; workspace prev_on_output
@ -195,28 +195,28 @@ bindsym $mod+Ctrl+Shift+k move container to workspace next; workspace next
#bindsym $mod+Ctrl+Shift+Up move container to workspace next; workspace next
# move focused container to workspace
bindsym $mod+ctrl+1 move container to workspace $ws1
bindsym $mod+ctrl+2 move container to workspace $ws2
bindsym $mod+ctrl+3 move container to workspace $ws3
bindsym $mod+ctrl+4 move container to workspace $ws4
bindsym $mod+ctrl+5 move container to workspace $ws5
bindsym $mod+ctrl+6 move container to workspace $ws6
bindsym $mod+ctrl+7 move container to workspace $ws7
bindsym $mod+ctrl+8 move container to workspace $ws8
bindsym $mod+ctrl+9 move container to workspace $ws9
bindsym $mod+ctrl+0 move container to workspace $ws10
bindsym $mod+ctrl+1 move container to workspace $ws1; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+2 move container to workspace $ws2; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+3 move container to workspace $ws3; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+4 move container to workspace $ws4; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+5 move container to workspace $ws5; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+6 move container to workspace $ws6; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+7 move container to workspace $ws7; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+8 move container to workspace $ws8; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+9 move container to workspace $ws9; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+0 move container to workspace $ws10; exec ~/.config/i3/focus_windows
# move to workspace with focused container
bindsym $mod+shift+1 move container to workspace $ws1; workspace $ws1
bindsym $mod+shift+2 move container to workspace $ws2; workspace $ws2
bindsym $mod+shift+3 move container to workspace $ws3; workspace $ws3
bindsym $mod+shift+4 move container to workspace $ws4; workspace $ws4
bindsym $mod+shift+5 move container to workspace $ws5; workspace $ws5
bindsym $mod+shift+6 move container to workspace $ws6; workspace $ws6
bindsym $mod+shift+7 move container to workspace $ws7; workspace $ws7
bindsym $mod+shift+8 move container to workspace $ws8; workspace $ws8
bindsym $mod+shift+9 move container to workspace $ws9; workspace $ws9
bindsym $mod+shift+0 move container to workspace $ws10; workspace $ws10
bindsym $mod+shift+1 move container to workspace $ws1; workspace $ws1; exec ~/.config/i3/focus_windows
bindsym $mod+shift+2 move container to workspace $ws2; workspace $ws2; exec ~/.config/i3/focus_windows
bindsym $mod+shift+3 move container to workspace $ws3; workspace $ws3; exec ~/.config/i3/focus_windows
bindsym $mod+shift+4 move container to workspace $ws4; workspace $ws4; exec ~/.config/i3/focus_windows
bindsym $mod+shift+5 move container to workspace $ws5; workspace $ws5; exec ~/.config/i3/focus_windows
bindsym $mod+shift+6 move container to workspace $ws6; workspace $ws6; exec ~/.config/i3/focus_windows
bindsym $mod+shift+7 move container to workspace $ws7; workspace $ws7; exec ~/.config/i3/focus_windows
bindsym $mod+shift+8 move container to workspace $ws8; workspace $ws8; exec ~/.config/i3/focus_windows
bindsym $mod+shift+9 move container to workspace $ws9; workspace $ws9; exec ~/.config/i3/focus_windows
bindsym $mod+shift+0 move container to workspace $ws10; workspace $ws10; exec ~/.config/i3/focus_windows
## move workspaces to screen
#bindsym $mod+ctrl+shift+r move workspace to output right
@ -225,10 +225,10 @@ bindsym $mod+shift+0 move container to workspace $ws10; workspace $ws10
#bindsym $mod+Ctrl+Shift+d move workspace to output below
# move workspaces to screen (arrow keys)
bindsym $mod+ctrl+shift+Right move workspace to output right
bindsym $mod+ctrl+shift+Left move workspace to output left
bindsym $mod+Ctrl+Shift+Up move workspace to output above
bindsym $mod+Ctrl+Shift+Down move workspace to output below
bindsym $mod+ctrl+shift+Right move workspace to output right; exec ~/.config/i3/focus_windows
bindsym $mod+ctrl+shift+Left move workspace to output left; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+Shift+Up move workspace to output above; exec ~/.config/i3/focus_windows
bindsym $mod+Ctrl+Shift+Down move workspace to output below; exec ~/.config/i3/focus_windows
# Default layout = tabs, since I mostly exclusively use them
workspace_layout tabbed
@ -290,10 +290,10 @@ mode "Resize" {
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym h resize shrink width 10 px or 10 ppt
bindsym j resize grow height 10 px or 10 ppt
bindsym k resize shrink height 10 px or 10 ppt
bindsym l resize grow width 10 px or 10 ppt
bindsym h resize shrink width 10 px or 10 ppt; exec ~/.config/i3/focus_windows
bindsym j resize grow height 10 px or 10 ppt; exec ~/.config/i3/focus_windows
bindsym k resize shrink height 10 px or 10 ppt; exec ~/.config/i3/focus_windows
bindsym l resize grow width 10 px or 10 ppt; exec ~/.config/i3/focus_windows
## same bindings, but for the arrow keys
#bindsym Left resize shrink width 10 px or 10 ppt

12
config/i3/focus_windows Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
XDT=/usr/bin/xdotool
WINDOW=`$XDT getwindowfocus`
# this brings in variables WIDTH and HEIGHT
eval `xdotool getwindowgeometry --shell $WINDOW`
TX=`expr $WIDTH / 2`
TY=`expr $HEIGHT / 2`
$XDT mousemove -window $WINDOW $TX $TY