X-Git-Url: https://git.donarmstrong.com/?p=deb_pkgs%2Fautorandr.git;a=blobdiff_plain;f=contrib%2Fpm-utils%2F40autorandr;h=80cda11bba44f0d2a0053f387322bbc0ebcf827b;hp=11291778c6b32dc28a479b562a0a2cd13bfef525;hb=737ca561f4d3dadacbbf5f561c58e7efceb0541e;hpb=2b3ac61cda7bea1269778c96246d6e66b9476010 diff --git a/contrib/pm-utils/40autorandr b/contrib/pm-utils/40autorandr index 1129177..80cda11 100755 --- a/contrib/pm-utils/40autorandr +++ b/contrib/pm-utils/40autorandr @@ -7,9 +7,19 @@ AUTORANDR="autorandr -c --default default" detect_display() { + # Wait for the system to recognize the changed state, see bug #30 + # Note the ampersand below, this runs asynchroneously. + sleep 5 + for X in /tmp/.X11-unix/X*; do D="${X##/tmp/.X11-unix/X}" - user=`who | awk -vD="$D" '$2 ~ ":"D"(.[0-9])?$" {print $1}' | head -1` + # Prefer w to who, see bug #39 + if [ -x "`which w`" ]; then + user="`w -h | awk -vD="$D" '$2 ~ ":"D"(.[0-9])?$" || $3 ~ ":"D"(.[0-9])?$" {print $1}' | head -n1`" + else + user="`who --all | awk -vD="$D" '$3 ~ ":"D"(.[0-9])?$" {print $1}' | head -1`" + fi + if [ x"$user" != x"" ]; then logger "autorandr: Changing display configuration for user '$user'" export DISPLAY=":$D" @@ -20,6 +30,6 @@ detect_display() case "$1" in thaw|resume) - detect_display + detect_display & ;; esac