From e896b6cb29fbb7377fefc8cd4fc6b0d72bfd6ccc Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 9 May 2024 19:38:01 -0300 Subject: Feat: xres: add optional interface arg --- xres | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'xres') diff --git a/xres b/xres index 5495b6c..90aff6b 100755 --- a/xres +++ b/xres @@ -7,10 +7,11 @@ BASENAME="`basename $0`" X="$1" Y="$2" +INTERFACE="$3" # Check if [ -z "$Y" ]; then - echo "usage: $BASENAME " + echo "usage: $BASENAME " exit 1 elif ! which cvt &> /dev/null; then echo "please install cvt from xserver-xorg-core" @@ -22,9 +23,13 @@ fi # Get modeline and interface MODELINE="`cvt $X $Y | grep -v '^#' | sed -e 's/^Modeline //'`" -INTERFACE="`xrandr | grep " connected" | cut -d ' ' -f 1 | head`" NAME="`echo $MODELINE | cut -d ' ' -f 1 | sed -e 's/"//g'`" +# Fallback to the first connected interface found +if [ -z "$INTERFACE" ]; then + INTERFACE="`xrandr | grep " connected" | cut -d ' ' -f 1 | head -1`" +fi + # Apply xrandr --newmode $MODELINE &> /dev/null xrandr --addmode $INTERFACE $NAME -- cgit v1.2.3