M .config/sway/config => .config/sway/config +6 -0
@@ 71,6 71,12 @@ output eDP-1 pos 0 0
# Start your launcher
bindsym $mod+d exec $menu
+ # Mouse keys
+ # You can get keynames using `xev -event keyboard | egrep -o 'keycode.*\)'`
+ bindsym Control+Return exec 'mousekeys_record.sh'
+ bindsym Control+Shift_R exec 'mousekeys_click.sh'
+ bindsym Control+slash exec 'mousekeys_jump.sh'
+
# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
A bin/mousekeys_click.sh => bin/mousekeys_click.sh +6 -0
@@ 0,0 1,6 @@
+swaymsg "seat * cursor press button1"
+
+RANDOM_SLEEP=$((1 + $RANDOM % 105))
+sleep "0.{$RANDOM_SLEEP}s"
+
+swaymsg "seat * cursor release button1"
A bin/mousekeys_jump.sh => bin/mousekeys_jump.sh +8 -0
@@ 0,0 1,8 @@
+RAND_X=$((-5 + $RANDOM % 15))
+RAND_Y=$((-5 + $RANDOM % 12))
+X=$(cat $HOME/.local/share/mousekeys_x)
+Y=$(cat $HOME/.local/share/mousekeys_y)
+X=$(calc "$X + $RAND_X")
+Y=$(calc "$Y + $RAND_Y")
+
+swaymsg "seat * cursor set $X $Y"
A bin/mousekeys_record.sh => bin/mousekeys_record.sh +12 -0
@@ 0,0 1,12 @@
+Y=$(xdotool getmouselocation | awk -F'[ :]' '{print $4}')
+X=$(xdotool getmouselocation | awk -F'[ :]' '{print $2}')
+
+# If we're hooked up to an external monitor
+# Subtract width of 1st screen from X coordinate
+NUM_DISPLAYS=$(swaymsg -t get_outputs | jq '. | length')
+if [[ $NUM_DISPLAYS = "2" ]]; then
+ X=$(calc "$X - 1920")
+fi
+
+echo $X > $HOME/.local/share/mousekeys_x
+echo $Y > $HOME/.local/share/mousekeys_y