Skip to main content
This page provides practical examples of automating Loop using shell scripts, AppleScript, and the URL scheme.

Shell Script Examples

Basic Window Movement

Simple commands for common window operations:
# Move window to right half
open "loop://direction/right"

# Maximize window
open "loop://action/maximize"

# Move to next screen
open "loop://screen/next"

Sequential Actions

Chain multiple actions together with delays:
#!/bin/bash
# Move window right and then maximize
open "loop://direction/right"
sleep 0.5
open "loop://action/maximize"
The sleep command ensures the first action completes before the next one starts.

Discovery Scripts

Query available commands and configurations:
# List all commands
open "loop://list/all"

# List window actions
open "loop://list/actions"

# List custom keybinds
open "loop://list/keybinds"

AppleScript Examples

Activating Loop

osascript -e 'tell application "Loop" to activate'

Window Commands

# Move window to left half
osascript -e 'open location "loop://direction/left"'

# Move window to right half
osascript -e 'open location "loop://direction/right"'

Automation Workflows

Multi-Step Window Layout

Create a complete workspace layout:
#!/bin/bash
# Set up a productivity layout

# Move current window to left half
open "loop://direction/left"
sleep 0.5

# Switch to next window (using system commands)
# Then move it to right half
open "loop://direction/right"

Screen Management Workflow

Move windows between displays:
#!/bin/bash
# Move window to next screen and maximize

open "loop://screen/next"
sleep 0.3
open "loop://action/maximize"

Integration Patterns

Combining URL Scheme and AppleScript

Use both approaches in the same script:
#!/bin/bash

# Activate Loop using AppleScript
osascript -e 'tell application "Loop" to activate'

# Execute window command using URL scheme
open "loop://direction/right"

# Wait and execute another command
sleep 0.5
osascript -e 'open location "loop://action/maximize"'

Keyboard Shortcut Automation

Create shell aliases for common operations:
# Add to ~/.bashrc or ~/.zshrc

alias loop-left="open 'loop://direction/left'"
alias loop-right="open 'loop://direction/right'"
alias loop-max="open 'loop://action/maximize'"
alias loop-next="open 'loop://screen/next'"
Then use them directly:
loop-left   # Move window to left half
loop-max    # Maximize window

Custom Keybind Execution

Trigger custom keybinds by name:
#!/bin/bash
# Execute a custom keybind layout

open "loop://keybind/myCustomLayout"

Advanced Examples

Conditional Window Management

Combine Loop with system queries:
#!/bin/bash
# Move window based on screen count

screen_count=$(system_profiler SPDisplaysDataType | grep -c "Resolution")

if [ $screen_count -gt 1 ]; then
    open "loop://screen/next"
else
    open "loop://direction/right"
fi

Timed Automation

Create time-based window layouts:
#!/bin/bash
# Different layouts for different times of day

hour=$(date +%H)

if [ $hour -lt 12 ]; then
    # Morning layout
    open "loop://direction/left"
else
    # Afternoon layout
    open "loop://direction/maximize"
fi

Tips for Effective Scripting

Use sleep commands between sequential actions to ensure each command completes before the next starts. A delay of 0.3-0.5 seconds is usually sufficient.
Test individual commands before combining them into complex scripts. Use loop://list/all to verify available commands.
Create shell aliases for frequently used commands to speed up your workflow.
Window commands operate on the frontmost non-terminal window. Make sure the correct window is active before running commands.

Next Steps

URL Scheme Reference

Complete URL command documentation

AppleScript Integration

AppleScript automation guide

Build docs developers (and LLMs) love