From 276d1740fed3dcfe6a2e4585b048d5b6d0122292 Mon Sep 17 00:00:00 2001 From: Maciej Sitarz Date: Wed, 18 Jan 2012 22:07:01 +0100 Subject: [PATCH] Added pm-utils hook to be run on resume/thaw. --- 00autorandr_pm-utils | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 00autorandr_pm-utils diff --git a/00autorandr_pm-utils b/00autorandr_pm-utils new file mode 100755 index 0000000..1637445 --- /dev/null +++ b/00autorandr_pm-utils @@ -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