3 # 40autorandr: Change autorandr profile on thaw/resume
4 exec > /var/log/autorandr.log 2>&1
6 AUTORANDR="autorandr -c --default default"
10 for X in /tmp/.X11-unix/X*; do
11 D="${X##/tmp/.X11-unix/X}"
12 # Prefer w to who, see bug #39
13 if [ -x "`which w`" ]; then
14 user="`w -h | awk -vD="$D" '$2 ~ ":"D"(.[0-9])?$" || $3 ~ ":"D"(.[0-9])?$" {print $1}' | head -n1`"
16 if [ -z "$user" ]; then
17 # This fallback checks if there is exactly one user (except
18 # root) logged in an interactive session and assumes the
19 # session belongs to him. See bug #39.
20 user="`w -hu | awk '/^\w+/ && $1 !~ "root" { users[$1]=$1; } ENDFILE { if(asort(users) == 1) for(u in users) print users[u]; }'`"
23 user="`who --all | awk -vD="$D" '$3 ~ ":"D"(.[0-9])?$" {print $1}' | head -1`"
25 if [ -z "$user" ]; then
26 # Same fallback as above; see bug #39.
27 user="`who -u | awk '/^\w+/ && $1 !~ "root" { users[$1]=$1; } ENDFILE { if(asort(users) == 1) for(u in users) print users[u]; }'`"
31 if [ x"$user" != x"" ]; then
32 logger "autorandr: Changing display configuration for display :$D, user '$user'"
34 /bin/su -c "${AUTORANDR}" "$user"
39 if grep -q systemd $(readlink -f $(awk '{print $1}' /proc/1/cmdline)) && [ "$2" = "udev" ]; then
40 exec /bin/systemctl start autorandr-resume.service