]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Added pm-utils hook to be run on resume/thaw.
authorMaciej Sitarz <macieksitarz@wp.pl>
Wed, 18 Jan 2012 21:07:01 +0000 (22:07 +0100)
committerStefan Tomanek <stefan.tomanek@wertarbyte.de>
Sun, 12 Feb 2012 22:12:26 +0000 (23:12 +0100)
00autorandr_pm-utils [new file with mode: 0755]

diff --git a/00autorandr_pm-utils b/00autorandr_pm-utils
new file mode 100755 (executable)
index 0000000..1637445
--- /dev/null
@@ -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