#!/usr/bin/env python

import sys

builtin_width = 2560
builtin_height = 1440
builtin_scale = 1

usage = f'Usage: {sys.argv[0]} <external_resolution> <scale>'

if len(sys.argv) != 3:
    print(usage)
    sys.exit(1)

external_res = sys.argv[1]
external_scale = float(sys.argv[2])

external_width = int(external_res.split('x')[0])
external_height = int(external_res.split('x')[1])

screen_width = int(external_width * external_scale)
screen_height = int(builtin_height + external_height * external_scale)

builtin_x_pos = int((screen_width - builtin_width) / 2)
builtin_y_pos = int(external_height * external_scale)

print(f'xrandr --fb {screen_width}x{screen_height} --output eDP1 --scale {builtin_scale}x{builtin_scale} --pos {builtin_x_pos}x{builtin_y_pos} --output HDMI2 --scale {external_scale}x{external_scale} --pos 0x0')
