I wrote a script called many_resolutions.py
which is used like:
python many_resolutions.py http://localhost:3000 800x600,0,0 1280x1024,2000,0
Where the screen spec is <width>x<height>,<x-position>,<y-position>
.
import subprocess, sys, os
CHROME='/usr/bin/google-chrome-stable'
webpage = sys.argv[1]
for screen_spec in sys.argv[2:]:
split = screen_spec.split(',')
if len(split) not in (1,3) or 1 > split[0].find('x'):
raise Exception('Screen arguments are <width>x<height>,<x-position>,<y-position>')
screen_res = split[0].split('x')
pos = None
if len(split) == 3:
pos = split[1:3]
cmd = [
CHROME,
'--profile-directory=Default',
'--app=data:text/html,<html><body><script>' +
('window.moveTo(' + pos[0] +',' + pos[1] + ');' if pos else '') +
'window.resizeTo(' + screen_res[0] + ',' + screen_res[1] + ');' +
'window.location="' + webpage + '";</script></body></html>',
]
print(cmd)
subprocess.Popen(cmd, preexec_fn=os.setpgrp)