#!/bin/sh -efu

show_help(){
  cat <<EOF
resolution_setup -- set display resolutions in xorg.conf

Usage: resolution_setup <maximum resolution> <config file>
EOF
exit 1
}


tail_res()
{
    sed -n "/$1/,\$ p" /usr/share/alterator-x11/resolutions|
	tr '\n' ','|
	sed 's/,$//'
}

[ "$#" = 2 ] || show_help

xresolution="$1";shift
config="$1";shift

[ "$xresolution"  = "auto" ] &&
  xresolution="" ||
  xresolution="$(tail_res "$xresolution")"


xconf -R "$xresolution" "$config" "$config"
