Updated pm-utils scripts

40autorandr had issues when resuming on a system where
one or more users have multiple terminal sessions open.

enhanced 40autorandr to allow being called as 40auto-disper
to automatically swap to using auto-disper semantics
This commit is contained in:
helterscelter 2012-08-06 15:08:08 -04:00
parent 72bced7aeb
commit afd63d5066
2 changed files with 17 additions and 3 deletions

1
pm-utils/40auto-disper Symbolic link
View File

@ -0,0 +1 @@
40autorandr

View File

@ -2,22 +2,35 @@
# #
# 40autorandr: Change autorandr profile on thaw/resume # 40autorandr: Change autorandr profile on thaw/resume
AUTORANDR="autorandr -c" # 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
echo "$AUTORANDR"
detect_display() detect_display()
{ {
for X in /tmp/.X11-unix/X*; do for X in /tmp/.X11-unix/X*; do
D="${X##/tmp/.X11-unix/X}" D="${X##/tmp/.X11-unix/X}"
user=$(who | awk -vD="$D" '$5 ~ "\\(:"D"\\)$" {print $1}') user=$( who | grep \(:$D\) | cut -d ' ' -sf 1 | uniq )
echo "Checking $X -- $D - $user"
if [ x"$user" != x"" ]; then if [ x"$user" != x"" ]; then
echo "AUTORANDR $D - $user"
export DISPLAY=":$D" export DISPLAY=":$D"
/bin/su -c "${AUTORANDR}" "$user" /bin/su -c "${AUTORANDR}" "$user"
fi fi
done done
echo "Done"
} }
case "$1" in case "$1" in
thaw|resume) thaw|resume)
detect_display detect_display
;; ;;
esac esac