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.
Get current display resolution and settings:
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")
import { Sandbox } from '@hopx-ai/sdk';
const sandbox = await Sandbox.create({ template: 'desktop' });
// Get display info
const display = await sandbox.desktop.getDisplayInfo();
console.log(`Resolution: ${display.width}x${display.height}`);
console.log(`Color depth: ${display.depth} bits`);
Setting Resolution
Set display resolution:
# 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}")
// Set resolution to 1920x1080
await sandbox.desktop.setResolution(1920, 1080);
// Verify
const display = await sandbox.desktop.getDisplayInfo();
console.log(`Resolution: ${display.width}x${display.height}`);
// Set to 1280x720
await sandbox.desktop.setResolution(1280, 720);
Available Resolutions
List available display resolutions:
# 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]}")
// Get available resolutions
const resolutions = await sandbox.desktop.getAvailableResolutions();
console.log('Available resolutions:');
resolutions.forEach(([width, height]) => {
console.log(` ${width}x${height}`);
});
// Find highest resolution
if (resolutions.length > 0) {
const highest = resolutions.reduce((a, b) =>
(a[0] * a[1] > b[0] * b[1]) ? a : b
);
console.log(`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:
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()
import { Sandbox } from '@hopx-ai/sdk';
const sandbox = await Sandbox.create({ template: 'desktop' });
try {
// Get current display
const current = await sandbox.desktop.getDisplayInfo();
console.log(`Current: ${current.width}x${current.height}`);
// List available resolutions
const resolutions = await sandbox.desktop.getAvailableResolutions();
console.log(`Available: ${resolutions.length} resolutions`);
// Set to Full HD
await sandbox.desktop.setResolution(1920, 1080);
// Verify
const verify = await sandbox.desktop.getDisplayInfo();
if (verify.width === 1920 && verify.height === 1080) {
console.log('✅ Resolution verified');
}
} finally {
await 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