Skip to content

Instantly share code, notes, and snippets.

@gcavanunez
Created November 20, 2023 13:42
Show Gist options
  • Save gcavanunez/eb198ebd140a445dd297a0deac71ea6d to your computer and use it in GitHub Desktop.
Save gcavanunez/eb198ebd140a445dd297a0deac71ea6d to your computer and use it in GitHub Desktop.
Mass move displays
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title All to main
# @raycast.mode compact
# Optional parameters:
# @raycast.icon �ü§ñ
# Documentation:
# @raycast.description Move
# @raycast.author Guillermo Antony Cava Nuñez
# @raycast.authorURL https://github.com/gcavanunez
property excludedApps : {"Raycast"} -- Add the names of the apps you want to exclude
tell application "System Events"
set screenResolution to do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2, $4}' | head -n 1"
-- set screenResolution to do shell script "system_profiler SPDisplaysDataType | awk '/Resolution/{print $2, $4}' | head -n 2 | tail -1 "
set {screen_width, screen_height} to words of screenResolution
repeat with theProcess in (every application process where background only is false and visible is true)
if name of theProcess is not in excludedApps then
repeat with theWindow in (every window of theProcess)
try
set position of theWindow to {90, 80} -- Set position with 20px margin
set size of theWindow to {screen_width - 180, screen_height - 160} -- Resize with 20px margin
on error errMsg
-- Optional error handling
end try
end repeat
end if
end repeat
end tell
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title All centered
# @raycast.mode compact
# Optional parameters:
# @raycast.icon �ü§ñ
# Documentation:
# @raycast.description Move
# @raycast.author Guillermo Antony Cava Nuñez
# @raycast.authorURL https://github.com/gcavanunez
property excludedApps: {"Raycast"} -- Add the names of the apps you want to exclude
tell application "System Events"
repeat with theProcess in (every application process where background only is false and visible is true)
if name of theProcess is not in excludedApps then
tell theProcess
repeat with theWindow in (every window)
try
-- Attempt to bring the window to the front
perform action "AXRaise" of theWindow
delay 0.1 -- Short delay to ensure the window comes to the front
-- Set the application of the window as the frontmost
set frontmost of theProcess to true
delay 0.1 -- Another short delay for the application to become active
-- Send the key code
keystroke return using {control down, option down, shift down}
delay 0.1 -- Optional delay between actions
on error errMsg
-- Optional error handling
end try
end repeat
end tell
end if
end repeat
end tell
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title All to next
# @raycast.mode compact
# Optional parameters:
# @raycast.icon �ü§ñ
# Documentation:
# @raycast.description Move
# @raycast.author Guillermo Antony Cava Nuñez
# @raycast.authorURL https://github.com/gcavanunez
property excludedApps: {"Raycast"} -- Add the names of the apps you want to exclude
tell application "System Events"
repeat with theProcess in (every application process where background only is false and visible is true)
if name of theProcess is not in excludedApps then
tell theProcess
repeat with theWindow in (every window)
try
-- Attempt to bring the window to the front
perform action "AXRaise" of theWindow
delay 0.2 -- Short delay to ensure the window comes to the front
-- Set the application of the window as the frontmost
set frontmost of theProcess to true
delay 0.2 -- Another short delay for the application to become active
-- Send the key code
keystroke return using {control down, option down, shift down}
delay 0.1 -- Optional delay between actions
-- Send the key code
keystroke key code 124 using {control down, command down}
delay 0.1 -- Optional delay between actions
on error errMsg
-- Optional error handling
end try
end repeat
end tell
end if
end repeat
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment