/usr/share/laptop-mode-tools/modules/dpms-standby is in laptop-mode-tools 1.71-2ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #! /bin/sh
#
# Laptop mode tools module: control X display standby / suspend / off using DPMS
#
# getXuser gets the X user belonging to the display in $displaynum.
# (This code was borrowed from the Debian acpi-support package.)
getXuser() {
user=`w -hs | awk '{ if ($3 == ":'$displaynum'" || $3 ~ /:'$displaynum'\..*/ || $2 == ":'$displaynum'" || $2 ~ /:'$displaynum'\..*/) { print $1; exit; } }'`
if [ x"$user" = x"" ]; then
startx=`pgrep -n startx`
if [ x"$startx" != x"" ]; then
user=`ps -o user --no-headers $startx`
fi
fi
export XAUTHORITY=""
if [ x"$user" != x"" ]; then
xauthdir=`getent passwd $user | cut -d: -f6`
if [ -f "$xauthdir/.Xauthority" ]; then
export XAUTHORITY=$xauthdir/.Xauthority
fi
else
export XAUTHORITY=""
fi
export XUSER=$user
}
# Set X screen standby/suspend/powerdown timing
if [ x$CONTROL_DPMS_STANDBY = x1 ] || [ x$ENABLE_AUTO_MODULES = x1 -a x$CONTROL_DPMS_STANDBY = xauto ]; then
if [ $ON_AC -eq 1 ]; then
if [ "$ACTIVATE" -eq 1 ]; then
STANDBY="$LM_AC_DPMS_STANDBY"
SUSPEND=$(($STANDBY+30))
OFF=$(($STANDBY+60))
else
STANDBY="$NOLM_AC_DPMS_STANDBY"
SUSPEND=$(($STANDBY+300))
OFF=$(($STANDBY+600))
fi
else
STANDBY="$BATT_DPMS_STANDBY"
SUSPEND=$(($STANDBY+30))
OFF=$(($STANDBY+60))
fi
# Loop through all X servers using their unix domain sockets.
# (Partly borrowed from the Debian acpi-support package.)
for x in /tmp/.X11-unix/*; do
if [ -e "$x" ] ; then
displaynum=`echo $x | sed -r 's#/tmp/.X11-unix/X([0-9]*)$#\1#'`
log "VERBOSE" "Determining Xauthority for display $displaynum"
getXuser;
if [ x"$XAUTHORITY" != x"" ]; then
export DISPLAY=":$displaynum"
if su $XUSER -c "xset dpms $STANDBY $SUSPEND $OFF" 2>> $OUTPUT | grep -q display 2>&1 ; then
log "VERBOSE" "Unable to set DPMS timeouts: X is not running on $DISPLAY"
else
log "VERBOSE" "Set screen $DISPLAY for the user $XUSER to standby in $STANDBY s, suspend in $SUSPEND s, powerdown in $OFF s using Xauthority $XAUTHORITY"
fi
else
log "VERBOSE" "Unable to determine Xauthority for display :$displaynum."
fi
fi
done
else
log "VERBOSE" "CONTROL_DPMS_STANDBY is disabled, skipping..."
fi
|