improve pm-utils script

This commit is contained in:
Stefan Tomanek 2012-02-12 23:22:19 +01:00
parent 5f7ce588b2
commit 0f63a4fc23
1 changed files with 4 additions and 8 deletions

View File

@ -1,21 +1,17 @@
#!/bin/sh
#
# 90autorandr: Change autorand profile on thaw/resume
# 90autorandr: Change autorandr profile on thaw/resume
AUTORANDR="autorandr -c"
detect_display()
{
for x in /tmp/.X11-unix/*; do
displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
user=$(who|awk '$5 ~ regexp {print $1}' regexp="\\\(:$displaynum\\\)")
if [ x"$user" = x"" ]; then
user=$(who|awk '$2 ~ regexp {print $1}' regexp=":$displaynum")
fi
for X in /tmp/.X11-unix/X*; do
D="${X##/tmp/.X11-unix/X}"
user=$(who | awk -vD="$D" '$5 ~ "\\(:"D"\\)$" {print $1}')
if [ x"$user" != x"" ]; then
export DISPLAY=":$displaynum"
/bin/su -c "${AUTORANDR}" "$user"
return 0
fi
done
}