Skip to content

Commit

Permalink
improve pm-utils script
Browse files Browse the repository at this point in the history
  • Loading branch information
wertarbyte committed Feb 13, 2012
1 parent 5f7ce58 commit 0f63a4f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions pm-utils/90autorandr
Original file line number Diff line number Diff line change
@@ -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
}
Expand Down

0 comments on commit 0f63a4f

Please sign in to comment.