mirror of
https://github.com/AquaMorph/dotfiles.git
synced 2025-04-29 17:25:34 +00:00
Mouse thumb gestures move windows around
This commit is contained in:
parent
39659417e1
commit
97d703070a
@ -25,7 +25,7 @@ exec_always --no-startup-id g13d --config ~/.config/g13/resolve.bind --logo ~/.c
|
||||
exec_always --no-startup-id setxkbmap -option 'caps:super'
|
||||
|
||||
# Starts Jack for audio
|
||||
exec_always --no-startup-id sh ~/.config/scripts/system-start-audio.sh
|
||||
exec --no-startup-id sh ~/.config/scripts/system-start-audio.sh
|
||||
|
||||
# Open Google Play Music on workspace 10
|
||||
for_window [title="Google Play Music Desktop Player"] move to workspace $ws10
|
||||
@ -60,7 +60,8 @@ for_window [title="^Steam Keyboard$"] floating enable
|
||||
for_window [class="^com-intellij-updater-Runner$" title="^Update$"] floating enable
|
||||
for_window [instance="^sun-awt-X11-XDialogPeer$" title="^Complete Installation$"] floating enable
|
||||
|
||||
# The side buttons move the window around
|
||||
# The side buttons move the desktop around
|
||||
bindsym --whole-window button9 exec python3 ~/.config/scripts/i3-mouse.py back
|
||||
bindsym --whole-window button8 exec python3 ~/.config/scripts/i3-mouse.py forward
|
||||
bindsym $mod+Tab exec python3 ~/.config/scripts/i3-mouse.py thumb
|
||||
|
||||
|
@ -2,14 +2,71 @@
|
||||
import i3ipc
|
||||
import sys
|
||||
import os
|
||||
import time
|
||||
import pyautogui
|
||||
from enum import Enum
|
||||
|
||||
# Enum for mouse direction
|
||||
class Direction(Enum):
|
||||
UP = 1
|
||||
LEFT = 2
|
||||
RIGHT = 3
|
||||
DOWN = 4
|
||||
NONE = 5
|
||||
|
||||
up = sys.argv[1] == 'up'
|
||||
# getPoints() returns x and y movement of mouse
|
||||
def getPoints():
|
||||
sen = 10
|
||||
t = 0
|
||||
delay = 0.01
|
||||
|
||||
x,y = pyautogui.position()
|
||||
while True:
|
||||
time.sleep(delay)
|
||||
t += delay
|
||||
if t > 0.5:
|
||||
return
|
||||
xp, yp = pyautogui.position()
|
||||
dx = x - xp
|
||||
dy = y - yp
|
||||
if abs(dx) > sen or abs(dy) > sen:
|
||||
break
|
||||
return dx, dy
|
||||
|
||||
#pointsToDirection() converts mouse movement points to a direction
|
||||
def pointsToDirection(points):
|
||||
if points is None:
|
||||
return
|
||||
x, y = points
|
||||
if abs(x) > abs(y):
|
||||
if x < 0:
|
||||
return Direction.RIGHT
|
||||
else:
|
||||
return Direction.LEFT
|
||||
else:
|
||||
if y > 0:
|
||||
return Direction.UP
|
||||
else:
|
||||
return Direction.DOWN
|
||||
|
||||
i3 = i3ipc.Connection()
|
||||
focused = i3.get_tree().find_focused()
|
||||
if focused.window_instance not in ['overwatch.exe']:
|
||||
if sys.argv[1] == 'forward':
|
||||
os.system('i3-msg workspace prev_on_output')
|
||||
else:
|
||||
os.system('i3-msg workspace next_on_output')
|
||||
command = sys.argv[1]
|
||||
|
||||
if command in ['back', 'forward']:
|
||||
if focused.window_instance not in ['overwatch.exe']:
|
||||
if sys.argv[1] == 'forward':
|
||||
i3.command('workspace prev_on_output')
|
||||
else:
|
||||
i3.command('workspace next_on_output')
|
||||
|
||||
elif command == 'thumb':
|
||||
direction = pointsToDirection(getPoints())
|
||||
if direction == Direction.UP:
|
||||
i3.command('move up')
|
||||
elif direction == Direction.RIGHT:
|
||||
i3.command('move right')
|
||||
elif direction == Direction.DOWN:
|
||||
i3.command('move down')
|
||||
elif direction == Direction.LEFT:
|
||||
i3.command('move left')
|
||||
|
Loading…
x
Reference in New Issue
Block a user