autorandr/pm-utils/40autorandr
Christian Autermann abd5e778d3 replaced w with who as w cuts off long user names
Conflicts:
	pm-utils/40autorandr
2014-08-18 12:56:49 +02:00

35 lines
706 B
Bash
Executable File

#!/bin/sh
#
# 40autorandr: Change autorandr profile on thaw/resume
exec > /var/log/autorandr.log 2>&1
# detect if we are being called as 40auto-disper or 40autorandr
FORM=${0##*40}
case $FORM in
auto-disper)
AUTORANDR="auto-disper -c --default default"
;;
*)
AUTORANDR="autorandr -c --default default"
;;
esac
detect_display()
{
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`
if [ x"$user" != x"" ]; then
logger "autorandr: Changing display configuration for user '$user'"
export DISPLAY=":$D"
/bin/su -c "${AUTORANDR}" "$user"
fi
done
}
case "$1" in
thaw|resume)
detect_display
;;
esac