autorandr/pm-utils/40autorandr

36 lines
687 B
Plaintext
Raw Normal View History

#!/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"
;;
*)
AUTORANDR="autorandr -c"
;;
esac
detect_display()
{
2012-02-12 22:22:19 +00:00
for X in /tmp/.X11-unix/X*; do
D="${X##/tmp/.X11-unix/X}"
user=$(w -h | awk -vD="$D" '$3 ~ ":"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
echo "Done"
}
case "$1" in
thaw|resume)
detect_display
;;
esac