X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=contrib%2Fpm-utils%2F40autorandr;h=a80926091539b6bb9c4cfe768f074e697ddd363f;hb=bae286948aaeced03357adccfb14d1ce84a568d1;hp=4d59012515821c54d630eeda5987f4b5a9653361;hpb=7a41c28a93e2907a34d9a90e1821b2233e149642;p=deb_pkgs%2Fautorandr.git diff --git a/contrib/pm-utils/40autorandr b/contrib/pm-utils/40autorandr index 4d59012..a809260 100755 --- a/contrib/pm-utils/40autorandr +++ b/contrib/pm-utils/40autorandr @@ -3,48 +3,8 @@ # 40autorandr: Change autorandr profile on thaw/resume exec > /var/log/autorandr.log 2>&1 -AUTORANDR="autorandr -c --default default" - -# Work around #44: Long user names in w -export PROCPS_USERLEN=32 - -detect_display() -{ - for X in /tmp/.X11-unix/X*; do - D="${X##/tmp/.X11-unix/X}" - # 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`" - - if [ -z "$user" ]; then - # This fallback checks if there is exactly one user (except - # root) logged in an interactive session and assumes the - # session belongs to him. See bug #39. - user="`w -hu | awk '/^\w+/ && $1 !~ "root" { users[$1]=$1; } ENDFILE { if(asort(users) == 1) for(u in users) print users[u]; }'`" - fi - else - user="`who --all | awk -vD="$D" '$3 ~ ":"D"(.[0-9])?$" {print $1}' | head -1`" - - if [ -z "$user" ]; then - # Same fallback as above; see bug #39. - user="`who -u | awk '/^\w+/ && $1 !~ "root" { users[$1]=$1; } ENDFILE { if(asort(users) == 1) for(u in users) print users[u]; }'`" - fi - fi - - if [ x"$user" != x"" ]; then - logger "autorandr: Changing display configuration for display :$D, user '$user'" - export DISPLAY=":$D" - /bin/su -c "${AUTORANDR}" "$user" - fi - done -} - -if grep -q systemd /proc/1/comm && [ "$2" = "udev" ]; then - exec /bin/systemctl start autorandr-resume.service -fi - case "$1" in thaw|resume) - detect_display + autorandr --batch -c --default default ;; esac