#!/usr/bin/env python3
from init import *
import argparse


def get_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description='Change the text scaling factor')
    parser.add_argument('-s', type=float, help='The value of text scaling factor')
    parsed_args = parser.parse_args()
    return parsed_args


if __name__ == '__main__':
    args = get_args()

    xrandr_info = capture("xrandr").stdout
    match = re.search(r'current\s+(\d+)\s+x\s+(\d+)', xrandr_info)
    width, height = (int(match.group(1)), int(match.group(2))) if match else (0, 0)
    print(width, height)
    text_scaling = 1
    if width > 1920 or height > 1200:
        text_scaling = 1.25
    if width > 2560 or height > 1600:
        text_scaling = 1.5
    execute(f'gsettings set org.gnome.desktop.interface text-scaling-factor {text_scaling}')
