[Pkg-acpi-devel] Bug#605219: Bug#605219: Last fix broke the functionality for me
Michael Meskes
meskes at debian.org
Wed Dec 1 12:53:43 UTC 2010
> Looking at /usr/share/acpi-support/power-funcs, I see that the problem
> is that my X line looks like this:
> /usr/bin/X11/X -nolisten tcp -auth /var/run/slim.auth vt07
So you hae no display number given at all?
> I did not restart X since the upgrade so I suppose that 0.138-1 was
> using something compatible with my system.
I honestly doubt that 0138-1 worked, the 0.137 series probably did though.
Could you please replace your /usr/share/acpi-support/power-funcs with the
attached file and try again?
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL
-------------- next part --------------
# a micro library of helper functions for the power scripts
umask 022;
PATH="$PATH:/usr/bin/X11"
POWERSTATE="/var/lib/acpi-support/powerstate"
pwf_error() {
logger -t${0##*/} -perr -- power-funcs: $*
exit 1
}
# getXuser gets the X user belonging to the display in $displaynum.
# If you want the foreground X user, use getXconsole!
getXuser() {
plist=$(pinky -fw) || pwf_error "pinky lost"
user=
while read l; do
set -- $l
eval lastpp=\$$#
for ds in $2 $lastpp; do
case $ds in
:$displaynum)
user=$1
break
;;
esac
done
[ -z "$user" ] || break
for ds in $2 $lastpp; do
case $ds in
:$displaynum.0)
user=$1
break
;;
esac
done
[ -z "$user" ] || break
done <<-EOF
$plist
EOF
if [ -z "$user" ]; then
startx=$(pgrep -n startx || :)
[ -z "$startx" ] || user=$(ps -o user --no-headers $startx || :)
fi
if [ x"$user" != x"" ]; then
for pid in `ps -U $user -o pid=`; do
if grep -z -q XAUTHORITY /proc/$pid/environ; then
export `grep -z XAUTHORITY /proc/$pid/environ`
break
fi
done
if [ -z $XAUTHORITY ]; then
eval userhome=~$user
export XAUTHORITY=$userhome/.Xauthority
fi
else
export XAUTHORITY=""
fi
export XUSER=$user
}
# getXconsole gets the foreground (console) X user
getXconsole() {
activeVT=$(fgconsole) || pwf_error "can't get active VT"
case $activeVT in
''|*[!0-9]*)
pwf_error "invalid active VT '$activeVT'"
;;
esac
cmdl="ps wt tty$activeVT --no-headers"
xproc=$($cmdl) || pwf_error "'$cmdl' failure"
[ "$xproc" ] || pwf_error "X process not found"
# less error prone display detection method?
# after a 'startx', something like this may show up:
# '9859 tty7 Ss+ 46:22 /usr/bin/X -nolisten tcp :0 -auth /tmp/serverauth.hHIwM1r8IL'
# (display is 8th word) but a gdm may show different:
# '1647 tty7 Ss+ 2:16 /usr/bin/X :0 -audit 0 -auth /var/lib/gdm/:0.Xauth -nolisten tcp vt7'
# (display is 6th word, and there's also a display like string in the 10th word)
# the original greedy sed regex:
# displaynum=`ps t tty$console | sed -n -re 's,.*/X .*:([0-9]+).*,\1,p'`
# matches the ':0' substring in the '-auth' option argument
# '/var/lib/gdm/:0.Xauth' in the example above, instead of the expected ':0'
# argument
set -- $xproc
# skip first 4 positional parameters
shift 4
# 1st positional parameter now should be X
case $1 in
*/Xorg|*/X)
shift
# match the 1st of the remaining positional parameters that looks like
# a display number
displaynum=
while [ $1 ]; do
case $1 in
:[0-9]*)
displaynum=$1
break
;;
esac
shift
done
if [ -n "$displaynum" ]; then
displaynum=${displaynum##*:}
displaynum=${displaynum%%.*}
case $displaynum in
*[!0-9]*)
pwf_error "invalid display number '$displaynum'"
;;
esac
export DISPLAY=":$displaynum"
fi
getXuser
;;
esac
}
ac_adapters() {
for x in /sys/class/power_supply/*; do
[ ! -d "$x" ] || ! read type <$x/type || [ "$type" != Mains ] || echo $x
done
}
getState() {
# Run through all power supply information. If we have only one that is online,
# then we are on AC power. If we find no power supplies at all, then we assume
# that we are on a desktop machine without power supply information and we are
# actually on AC.
ONLINE_POWER_SUPPLY_PRESENT=0
POWER_SUPPLY_PRESENT=0
for x in $(ac_adapters); do
POWER_SUPPLY_PRESENT=1
! read _olpsp <$x/online || [ "$_olpsp" != 1 ] ||
ONLINE_POWER_SUPPLY_PRESENT=1
done
for x in /proc/acpi/ac_adapter/*; do
if [ -d "$x" ] ; then
POWER_SUPPLY_PRESENT=1
! read _olpsp <$x/state || [ "$_olpsp" != on-line ] ||
ONLINE_POWER_SUPPLY_PRESENT=1
fi
done
if [ $POWER_SUPPLY_PRESENT = 1 ] && [ $ONLINE_POWER_SUPPLY_PRESENT = 0 ] ; then
STATE="BATTERY";
else
STATE="AC"
fi
}
#check our state has actually changed
checkStateChanged() {
# do we have our state stashed?
# XXX: if vaiable STATE is unset, set it to the null string
: ${STATE=${STATE:-}}
# XXX: make sure variable STATE has a non-null value
[ "$STATE" ] || getState
if [ -f "$POWERSTATE" ]; then
# XXX: unset or empty variable STATE and an existing but empty POWERSTATE file
# and the function will probably have undesired side effects
read OLDSTATE <$POWERSTATE || :
if [ "$STATE" = "$OLDSTATE" ]; then
exit 0
else
#stash the new state
# XXX: unset or empty variable STATE, will create an empty POWERSTATE file
echo "$STATE" > $POWERSTATE
fi
else
#we need to stash the new state
# XXX: unset or empty variable STATE, will create an empty POWERSTATE file
echo "$STATE" > $POWERSTATE
fi
}
HDPARM='/sbin/hdparm -q'
LIDSTATE='/var/lib/acpi-support/lidstate'
More information about the Pkg-acpi-devel
mailing list