Package: hibernate
Version: 1.99-1.1
Severity: wishlist

I found no option to run commands with environment set up so that they
can connect to the X server.

There is LockXScreensaver option already so I modified it to allow
executing arbitrary user commands.

Perhaps it could be futher improver by allowing a list of programs to
search for rather than a single program.


-- Package-specific info:
--- configuration
==> /etc/hibernate/common.conf <==
Verbosity 0
LogFile /var/log/hibernate.log
LogVerbosity 3
 AlwaysKill yes
Distribution debian
SaveClock restore-only
 LockXScreenSaver yes
XOnResume 02 wacset
XOnResume 02 lmouse
UnloadModules wacom button
UnloadBlacklistedModules yes
LoadModules auto
IncompatiblePrograms xmms2d
RestartServices acpid
SwitchToTextMode yes
XStatus x
XmessageDisable yes
XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' 
--colour=Green --shadow 1 --pos bottom --align center --offset 50
==> /etc/hibernate/disk.conf <==
TryMethod ususpend-disk.conf
TryMethod sysfs-disk.conf
==> /etc/hibernate/hibernate.conf <==
TryMethod suspend2.conf
TryMethod disk.conf
TryMethod ram.conf
==> /etc/hibernate/ram.conf <==
TryMethod ususpend-ram.conf
TryMethod sysfs-ram.conf
==> /etc/hibernate/suspend2.conf <==
UseSuspend2 yes
Reboot no
EnableEscape yes
DefaultConsoleLevel 1
Compressor lzf
Encryptor none
FullSpeedCPU yes
Include common.conf
==> /etc/hibernate/sysfs-disk.conf <==
UseSysfsPowerState disk
Include common.conf
==> /etc/hibernate/sysfs-ram.conf <==
UseSysfsPowerState mem
Include common.conf
==> /etc/hibernate/ususpend-both.conf <==
USuspendMethod both
Include common.conf
==> /etc/hibernate/ususpend-disk.conf <==
USuspendMethod disk
Include common.conf
==> /etc/hibernate/ususpend-ram.conf <==
USuspendMethod ram
Include common.conf

--- /sys/power
==> /sys/power/disk <==
[platform] test testproc shutdown reboot 
==> /sys/power/image_size <==
481067499
==> /sys/power/pm_async <==
1
==> /sys/power/pm_test <==
[none] core processors platform devices freezer
==> /sys/power/resume <==
8:6
==> /sys/power/state <==
standby mem disk
==> /sys/power/wakeup_count <==
0

--- log

-- System Information:
Debian Release: squeeze/sid
  APT prefers stable
  APT policy: (990, 'stable'), (500, 'testing'), (300, 'unstable'), (295, 
'experimental'), (290, 'stable-i386'), (280, 'testing-i386'), (270, 
'unstable-i386'), (150, 'experimental-i386')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.36-rc4-r600fence-netpollirq-smbinit-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages hibernate depends on:
ii  console-tools            1:0.2.3dbs-65.1 Linux console and font utilities

Versions of packages hibernate recommends:
ii  dash                          0.5.5.1-6  POSIX-compliant shell
ii  hdparm                        8.9-3      tune hard disk parameters for high
ii  uswsusp                       0.8-1.2+b1 tools to use userspace software su
ii  vbetool                       1.0-3      run real-mode video BIOS code to a

Versions of packages hibernate suggests:
pn  915resolution                 <none>     (no description available)
ii  xscreensaver                  5.11-1+b1  Automatic screensaver for X

-- Configuration Files:
/etc/hibernate/blacklisted-modules changed:
nvidia
acx100
acx_pci
hsfmodem
prism54
oss_hdaudio
bcm4400         2.6.0   2.6.99
emu10k1         2.4.0   2.4.99  2.6.0   2.6.99
forcedeth       2.4.0   2.4.99  2.6.0   2.6.99
@ipw2100        0.0     1.0.2
@ipw2200        0.0     0.20
natsemi         2.6.0   2.6.99
psmouse         2.6.0   2.6.19
rt2400          2.4.0   2.4.99  2.6.0   2.6.99
ehci_hcd        2.6.0   2.6.14
ohci_hcd        2.6.0   2.6.14
uhci_hcd        2.6.0   2.6.14
ehci-hcd        2.4.0   2.4.99
usb-ohci        2.4.0   2.4.99
usb-uhci        2.4.0   2.4.99
snd_ens1370     2.6.0   2.6.99
snd_ens1371     2.6.0   2.6.99
snd_maestro3    2.6.0   2.6.99
@snd_bt_sco     0.0     1.18
en1370          2.6.0   2.6.99
en1371          2.6.0   2.6.99
via_agp         2.6.0   2.6.8
via_rhine       2.6.0   2.6.99
i8042           2.6.10  2.6.99
intel_mch_agp   2.6.0   2.6.99
rt2500          2.6.0   2.6.14
button          2.6.9   2.6.22
speedstep_smi   2.6.12  2.6.99
@ndiswrapper    0.10    0.11
ath_pci
ipw3945
iwl3945
mac80211
sky2
uvcvideo

/etc/hibernate/common.conf changed:
Verbosity 0
LogFile /var/log/hibernate.log
LogVerbosity 3
 AlwaysKill yes
Distribution debian
SaveClock restore-only
 LockXScreenSaver yes
XOnResume 02 wacset
XOnResume 02 lmouse
UnloadModules wacom button
UnloadBlacklistedModules yes
LoadModules auto
IncompatiblePrograms xmms2d
RestartServices acpid
SwitchToTextMode yes
XStatus x
XmessageDisable yes
XosdSettings --font '-misc-fixed-medium-r-semicondensed--*-120-*-*-c-*-*-*' 
--colour=Green --shadow 1 --pos bottom --align center --offset 50


-- no debconf information

-- debsums errors found:
debsums: no md5sums for hibernate
# -*- sh -*-
# vim:ft=sh:ts=8:sw=4:noet

X_PROGRAM=xscreensaver

AddConfigHandler XMiscLaunchOptions
AddConfigHelp "XProgram <program used to find the X session. xscreensaver or a 
session manager is a good candidate."
AddConfigHelp "XOnSuspend NN <program to execute> [parameters for program]" 
"Executes a given program before suspending. NN is a two-digit number between 
00 and 99, inclusive - a higher number means the program will be executed later 
in the suspend process. See the ORDERING section in the SCRIPTLET-API for 
details."
AddConfigHelp "XOnResume NN <program to execute> [parameters for program]" 
"Executes a given program after resuming. NN is a number between 00 and 99, 
inclusive - a higher number means the program will be executed earlier in the 
resume process. See the ORDERING section in the SCRIPTLET-API for details."

XRun() {

    local xpid
    for xpid in `pidof "$X_PROGRAM"` ; do
        local xuser xdisp xauth xhome
        xuser=$(awk 'BEGIN{RS="\\000";FS="="}($1 == "USER"){print $2}' < 
/proc/$xpid/environ)
        xdisp=$(awk 'BEGIN{RS="\\000";FS="="}($1 == "DISPLAY"){print $2}' < 
/proc/$xpid/environ)
        xauth=$(awk 'BEGIN{RS="\\000";FS="="}($1 == "XAUTHORITY"){print $2}' < 
/proc/$xpid/environ)
        if [ -z "$xauth" ] ; then
            xhome=$(awk 'BEGIN{RS="\\000";FS="="}($1 == "HOME"){print $2}' < 
/proc/$xpid/environ)
            xauth="$xhome/.Xauthority"
        fi

        vecho 2 "Running $@ on $xuser's display $xdisp using authority file 
$xauth"
        DISPLAY=$xdisp XAUTHORITY=$xauth su $xuser -c "$*"
        if [ $? -ne 0 ] ; then
            vecho 0 "Failed to run $@ on $xdisp using authority file $xauth."
        fi
    done

    # Failing is silly. What would they do about it?
    return 0
}

XMISC_LAUNCH_COUNT=0

XMiscLaunchSuspendProg() {
    local tmpf
    MISC_LAUNCH_COUNT=$(($MISC_LAUNCH_COUNT+1))
    tmpf=`mktemp /tmp/tmp.hibernate.XXXXXX`
    AddSuspendHook $1 XMiscLaunchAuxFunc$MISC_LAUNCH_COUNT
    shift
    cat <<EOT > $tmpf
XMiscLaunchAuxFunc${MISC_LAUNCH_COUNT}() {
    vcat 3 <<EOT2
Executing XRun $...@...
EOT2
    XRun $@
    [ \$? -ne 0 ] && return 1
    return 0
}
EOT
    . $tmpf
    rm -f $tmpf
}

XMiscLaunchResumeProg() {
    local tmpf
    MISC_LAUNCH_COUNT=$(($MISC_LAUNCH_COUNT+1))
    tmpf=`mktemp /tmp/tmp.hibernate.XXXXXX`
    AddResumeHook $1 XMiscLaunchAuxFunc$MISC_LAUNCH_COUNT
    shift
    cat <<EOT > $tmpf
XMiscLaunchAuxFunc${MISC_LAUNCH_COUNT}() {
    vcat 3 <<EOT2
Executing XRun $...@...
EOT2
    XRun $@
    [ \$? -ne 0 ] && return 1
    return 0
}
EOT
    . $tmpf
    rm -f $tmpf
}

XMiscLaunchOptions() {
    case $1 in
        xonsuspend)
            shift
            if ! IsANumber $1 ; then
                vecho 0 "First argument to XOnSuspend must be a number between 
00 and 99!"
                exit 1
            fi
            XMiscLaunchSuspendProg $*
            ;;
        xonresume)
            shift
            if ! IsANumber $1 ; then
                vecho 0 "First argument to XOnResume must be a number between 
00 and 99!"
                exit 1
            fi
            XMiscLaunchResumeProg $*
            ;;
        xprogram)
            shift
            if [ -z "$1" ] ; then
                vecho 0 "XProgram requires a program name as argument!"
                exit 1
            fi
            X_PROGRAM="$1"
            ;;
        *)
            return 1
    esac
    return 0
}

Reply via email to