aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xxres41
1 files changed, 35 insertions, 6 deletions
diff --git a/xres b/xres
index 90aff6b..273e2ee 100755
--- a/xres
+++ b/xres
@@ -5,13 +5,29 @@
# Parameters
BASENAME="`basename $0`"
-X="$1"
-Y="$2"
-INTERFACE="$3"
+RESOLUTION="$1"
+INTERFACE="$2"
+#XRES="$1"
+#YRES="$2"
+#INTERFACE="$3"
# Check
-if [ -z "$Y" ]; then
- echo "usage: $BASENAME <x-res> <y-res> <interface>"
+#if [ -z "$Y" ]; then
+if [ -z "$RESOLUTION" ]; then
+ #echo "usage: $BASENAME <x-res> <y-res> <interface>"
+ echo "usage: $BASENAME <x-res>x<y-res> <interface>"
+ echo "example:"
+ echo ""
+ echo " $BASENAME HDMI-2 1680x1050"
+ echo ""
+ echo "for simpler usage, try xrandr directly, like:"
+ echo ""
+ echo " xrandr --output HDMI-2 --mode 1680x1050"
+ echo ""
+ echo "Available screens and resolutions"
+ echo "---------------------------------"
+ echo ""
+ xrandr
exit 1
elif ! which cvt &> /dev/null; then
echo "please install cvt from xserver-xorg-core"
@@ -21,8 +37,21 @@ elif ! which xrandr &> /dev/null; then
exit 1
fi
+# Parse resolution
+XRES="`echo $RESOLUTION | cut -d 'x' -f 1`"
+YRES="`echo $RESOLUTION | cut -d 'x' -f 2`"
+
+# Check resolution
+if [ -z "$XRES" ]; then
+ echo "$BASENAME: invalid value for x-res"
+ exit 1
+elif [ -z "$YRES" ]; then
+ echo "$BASENAME: invalid value for y-res"
+ exit 1
+fi
+
# Get modeline and interface
-MODELINE="`cvt $X $Y | grep -v '^#' | sed -e 's/^Modeline //'`"
+MODELINE="`cvt $XRES $YRES | grep -v '^#' | sed -e 's/^Modeline //'`"
NAME="`echo $MODELINE | cut -d ' ' -f 1 | sed -e 's/"//g'`"
# Fallback to the first connected interface found