Skip to main content
Configure display resolution and settings for the desktop environment.

Overview

Display management enables:
  • Getting current display resolution
  • Setting display resolution
  • Listing available resolutions
  • Configuring display settings
Desktop automation requires a template with desktop support. Ensure your sandbox has desktop capabilities enabled.

Getting Display Information

Get current display resolution and settings:
  • Python
  • JavaScript
from hopx_ai import Sandbox

sandbox = Sandbox.create(template="desktop")

# Get display info
display = sandbox.desktop.get_display()

print(f"Resolution: {display.width}x{display.height}")
print(f"Color depth: {display.depth} bits")

Setting Resolution

Set display resolution:
  • Python
  • JavaScript
# Set resolution to 1920x1080
display = sandbox.desktop.set_resolution(1920, 1080)

print(f"New resolution: {display.width}x{display.height}")

# Set to 1280x720
display = sandbox.desktop.set_resolution(1280, 720)
print(f"Resolution: {display.width}x{display.height}")

Available Resolutions

List available display resolutions:
  • Python
  • JavaScript
# Get available resolutions
resolutions = sandbox.desktop.get_available_resolutions()

print("Available resolutions:")
for width, height in resolutions:
    print(f"  {width}x{height}")

# Find highest resolution
if resolutions:
    highest = max(resolutions, key=lambda r: r[0] * r[1])
    print(f"Highest: {highest[0]}x{highest[1]}")

Common Resolutions

Common display resolutions:
  • 1920x1080: Full HD (1080p) - Recommended
  • 1280x720: HD (720p)
  • 2560x1440: 2K (1440p)
  • 3840x2160: 4K (2160p)

Complete Example

Complete display management workflow:
  • Python
  • JavaScript
from hopx_ai import Sandbox

sandbox = Sandbox.create(template="desktop")

try:
    # Get current display
    current = sandbox.desktop.get_display()
    print(f"Current: {current.width}x{current.height}")
    
    # List available resolutions
    resolutions = sandbox.desktop.get_available_resolutions()
    print(f"Available: {len(resolutions)} resolutions")
    
    # Set to Full HD
    display = sandbox.desktop.set_resolution(1920, 1080)
    print(f"Set to: {display.width}x{display.height}")
    
    # Verify
    verify = sandbox.desktop.get_display()
    assert verify.width == 1920 and verify.height == 1080
    print("✅ Resolution verified")
    
finally:
    sandbox.kill()

Resolution Best Practices

Set display resolution before starting VNC server for optimal remote desktop experience.
  • Before VNC: Set resolution before starting VNC for best results
  • Standard sizes: Use common resolutions (1920x1080, 1280x720) for compatibility
  • Testing: Test different resolutions for your use case

Next Steps