]> gitweb.fluxo.info Git - utils-x11.git/commitdiff
Feat: xres: add optional interface arg
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 9 May 2024 22:38:01 +0000 (19:38 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 9 May 2024 22:38:01 +0000 (19:38 -0300)
xres

diff --git a/xres b/xres
index 5495b6c36b0410207d66d04f5fc0aa8ce2940e20..90aff6b3eb9b910115682d8896533875c63c49a9 100755 (executable)
--- 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 <x-res> <y-res>"
+  echo "usage: $BASENAME <x-res> <y-res> <interface>"
   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