Skip to content

Commit

Permalink
Added pm-utils hook to be run on resume/thaw.
Browse files Browse the repository at this point in the history
  • Loading branch information
maciex authored and wertarbyte committed Feb 12, 2012
1 parent c67eb9c commit 276d174
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions 00autorandr_pm-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
#
# 90autorandr: Change autorand 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
if [ x"$user" != x"" ]; then
export DISPLAY=":$displaynum"
/bin/su -c "${AUTORANDR}" "$user"
return 0
fi
done
}

case "$1" in
thaw|resume)
detect_display
;;
esac

0 comments on commit 276d174

Please sign in to comment.