[Debian-eeepc-commits] [SCM] Maintenance of eeepc-acpi-scripts debian package branch, master, updated. a003008367dc02c38b813c1a074889a4c7602705
Darren Salt
linux at youmustbejoking.demon.co.uk
Mon Feb 2 17:49:54 UTC 2009
The following commit has been merged in the master branch:
commit 5782cf6b11760a1e5be72e84891c8950ca1ab1bc
Author: Darren Salt <linux at youmustbejoking.demon.co.uk>
Date: Wed Dec 3 13:51:43 2008 +0000
Detect user by looking for who owns a currently-running X session.
This even works for login managers :-)
diff --git a/debian/changelog b/debian/changelog
index b8419e3..349cc68 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,10 @@
eeepc-acpi-scripts (1.0.12) UNRELEASED; urgency=low
+ * Detect who's running an X session by looking for a controlling process
+ with DISPLAY set in its environment.
+ This has a useful side effect: status changes can be displayed even when
+ the controlling process is a login manager.
+
-- Darren Salt <linux at youmustbejoking.demon.co.uk> Mon, 02 Feb 2009 16:55:55 +0000
eeepc-acpi-scripts (1.0.11) unstable; urgency=low
diff --git a/functions.sh b/functions.sh
index 77389ff..655be91 100644
--- a/functions.sh
+++ b/functions.sh
@@ -24,7 +24,17 @@ detect_x_display()
# try the first logged user without any filters
# useful for users starting X via 'startx' after logging
# on the console
- _user=$( who | head -n 1 | cut -d' ' -f1 )
+ #_user=$( who | head -n 1 | cut -d' ' -f1 )
+ _user=$(ps -o pid= -t tty$(fgconsole) | sed -e 's/^\s\+//g' | cut -d' ' -f1)
+ if [ "${_user}" != '' ]; then
+ eval $(sed -e 's/\x00/\n/g' /proc/${_user}/environ | grep '^\(DISPLAY\|XAUTHORITY\)=' | sed -e "s/'/'\\\\''/g; s/=/='/; s/$/'/")
+ DISPLAY="${DISPLAY:-:0}"
+ export XAUTHORITY
+ export DISPLAY
+ user=root
+ home=$(getent passwd $_user | cut -d: -f6)
+ fi
+ return
fi
_home=$(getent passwd $_user | cut -d: -f6)
XAUTHORITY=$_home/.Xauthority
--
Maintenance of eeepc-acpi-scripts debian package
More information about the Debian-eeepc-commits
mailing list