window resize functionalliy (nice)

finally!
This commit is contained in:
2026-01-29 13:12:21 -05:00
parent de1b115a75
commit c0f43b4091
5 changed files with 69 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3
"""
Core module for resizing the active window on macOS.
"""
import subprocess
import sys
def resize_active_window(width: int, height: int):
"""
Resize the currently active window to the specified dimensions.
Keeps the window in its current position.
Args:
width: Target width in pixels
height: Target height in pixels
"""
applescript = f'''
tell application "System Events"
set frontApp to first application process whose frontmost is true
tell frontApp
set size of window 1 to {{{width}, {height}}}
end tell
end tell
'''
try:
subprocess.run(['osascript', '-e', applescript], check=True, capture_output=True)
print(f"✓ Resized active window to {width}x{height}")
except subprocess.CalledProcessError as e:
print(f"✗ Error resizing window: {e.stderr.decode()}")
sys.exit(1)