~tormodvolden/ubuntu/karmic/laptop-mode-tools/dupl-hook

« back to all changes in this revision

Viewing changes to usr/share/laptop-mode-tools/modules/dpms-standby

  • Committer: Bazaar Package Importer
  • Author(s): Tormod Volden
  • Date: 2008-05-12 16:24:50 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080512162450-n0lm5jnbafdf89l0
Tags: 1.42-1ubuntu1
* Merge from debian unstable (LP: #229579), remaining changes:
  - etc/init.d/laptop-mode: Check if laptop mode is disabled in
    /etc/default/laptop-mode (that's the file laptop_mode looks into, too,
    but it incorrectly evaluates the ENABLE_LAPTOP_MODE setting) as well
    as in /etc/default/acpi-support.
  - /usr/sbin/laptop_mode: Do not parse arguments, ignore "force" and
    "init" and let start/stop mean enable/disable.
  - /usr/sbin/laptop_mode: Do not read $ACTIVATE_WITH_POSSIBLE_DATA_LOSS
    from /var/run/laptop-mode-state to see if state has changed.
  - debian/rules: Do not ship acpi/apm scripts (we handle that ourselves)
  - debian/laptop-mode-tools.preinst: Remove any old acpi/apm scripts
  - debian/laptop-mode-tools.postinst: Create /etc/default/laptop-mode
    (with ENABLE_LAPTOP_MODE=false) if the file does not exist yet and we
    are on ppc.
  - debian/control: Change maintainer
* Use #DEBHELPER# in .postinst and .preinst (LP: #226788)
* Avoid using temporary files in init script to avoid hangs on
  shutdown if filesystem is read-only (LP: #206217)
* Also accept "stop" as second argument since the init script
  calls laptop_mode with "init stop"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
#
 
3
# Laptop mode tools module: control X display standby / suspend / off using DPMS
 
4
#
 
5
 
 
6
 
 
7
# Set X screen standby/suspend/powerdown timing
 
8
if [ $CONTROL_DPMS_STANDBY -eq 1 ] ; then
 
9
        if [ $ON_AC -eq 1 ]; then
 
10
                if [ "$ACTIVATE" -eq 1 ]; then
 
11
                        STANDBY="$LM_AC_DPMS_STANDBY"
 
12
                        SUSPEND=$(($STANDBY+30))
 
13
                        OFF=$(($STANDBY+60))
 
14
                else
 
15
                        STANDBY="$NOLM_AC_DPMS_STANDBY"
 
16
                        SUSPEND=$(($STANDBY+300))
 
17
                        OFF=$(($STANDBY+600))
 
18
                fi
 
19
        else
 
20
                STANDBY="$BATT_DPMS_STANDBY"
 
21
                SUSPEND=$(($STANDBY+30))
 
22
                OFF=$(($STANDBY+60))
 
23
        fi
 
24
 
 
25
        who | while read -r DPMS_USER DPMS_SCREEN REMAINDER; do         
 
26
                if su $DPMS_USER -c "xset -d $DPMS_SCREEN dpms $STANDBY $SUSPEND $OFF" 2>> $OUTPUT | grep -q display >> $OUTPUT 2>&1 ; then
 
27
                        echo "Unable to set DPMS timeouts: X is not running on $DPMS_SCREEN" >> $OUTPUT
 
28
                else 
 
29
                        echo "Set screen $DPMS_SCREEN for the user $DPMS_USER to standby in $STANDBY s, suspend in $SUSPEND s, powerdown in $OFF s" >> $OUTPUT
 
30
                fi      
 
31
        done
 
32
else
 
33
        echo "CONTROL_DPMS_STANDBY is disabled, skipping..." >> $OUTPUT
 
34
fi