From 0f63a4fc230f0b2d7079f87d47ca2eedca300249 Mon Sep 17 00:00:00 2001 From: Stefan Tomanek Date: Sun, 12 Feb 2012 23:22:19 +0100 Subject: [PATCH] improve pm-utils script --- pm-utils/90autorandr | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/pm-utils/90autorandr b/pm-utils/90autorandr index 1637445..59992a8 100755 --- a/pm-utils/90autorandr +++ b/pm-utils/90autorandr @@ -1,21 +1,17 @@ #!/bin/sh # -# 90autorandr: Change autorand profile on thaw/resume +# 90autorandr: Change autorandr profile on thaw/resume AUTORANDR="autorandr -c" detect_display() { - for x in /tmp/.X11-unix/*; do - displaynum=`echo $x | sed s#/tmp/.X11-unix/X##` - user=$(who|awk '$5 ~ regexp {print $1}' regexp="\\\(:$displaynum\\\)") - if [ x"$user" = x"" ]; then - user=$(who|awk '$2 ~ regexp {print $1}' regexp=":$displaynum") - fi + for X in /tmp/.X11-unix/X*; do + D="${X##/tmp/.X11-unix/X}" + user=$(who | awk -vD="$D" '$5 ~ "\\(:"D"\\)$" {print $1}') if [ x"$user" != x"" ]; then export DISPLAY=":$displaynum" /bin/su -c "${AUTORANDR}" "$user" - return 0 fi done }