]> gitweb.fluxo.info Git - utils-x11.git/commitdiff
Updates xres
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 10 Jan 2017 15:35:57 +0000 (13:35 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 10 Jan 2017 15:35:57 +0000 (13:35 -0200)
xres

diff --git a/xres b/xres
index 200753dfbc510d34ff3a5ea7f9e043bd016fdff5..d2b22c3830b12da95e24b739c7498ad87d43ab0f 100755 (executable)
--- a/xres
+++ b/xres
@@ -21,11 +21,15 @@ elif ! which xrandr &> /dev/null; then
 fi
 
 # Get modeline and interface
-MODELINE="`cvt $X $Y | grep -v '^#'` | sed -e 's/^Modeline //'"
+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'`"
+NAME="`echo $MODELINE | cut -d ' ' -f 1 | sed -e 's/"//g'`"
+
+# Add modeline
+if ! xrandr | grep -q $NAME; then
+  xrandr --newmode $MODELINE
+fi
 
 # Apply
-xrandr --newmode $MODELINE
 xrandr --addmode $INTERFACE $NAME
 xrandr --output  $INTERFACE --mode $NAME