PageRenderTime 82ms CodeModel.GetById 60ms app.highlight 3ms RepoModel.GetById 18ms app.codeStats 0ms

/acpi/sleep.sh

http://github.com/brinkman83/bashrc
Shell | 42 lines | 25 code | 8 blank | 9 comment | 15 complexity | bb9a2a96911a1bfbd2dc725a00092a88 MD5 | raw file
 1#!/bin/bash
 2# TODO:  Change above to /bin/sh
 3
 4# This script HANDLES the sleep button (does not TRANSLATE it). It is part
 5# of the *suspend* side of acpi-support, not the special keys translation
 6# side. If this script is called, it is assumed to be the result of a suspend
 7# key press that can also be heard by other parts of the system. The only time
 8# that it actually does something is when it is determined that no other parts
 9# of the system are listening (this is what the CheckPolicy call does).
10
11test -f /usr/share/acpi-support/key-constants || exit 0
12
13. /etc/default/acpi-support
14. /usr/share/acpi-support/power-funcs
15. /usr/share/acpi-support/device-funcs
16. /usr/share/acpi-support/policy-funcs
17
18DeviceConfig;
19
20if [ x$ACPI_SLEEP != xtrue ] && [ x$1 != xforce ]; then
21  exit;
22fi
23
24# If gnome-power-manager or klaptopdaemon are running, let them handle policy
25if [ x$1 != xforce ] && [ x$1 != xsleep ] && [ `CheckPolicy` = 0 ]; then
26    exit;
27fi
28
29if [ x$LOCK_SCREEN = xtrue ]; then
30    if pidof xscreensaver > /dev/null; then
31	for x in /tmp/.X11-unix/*; do
32	    displaynum=`echo $x | sed s#/tmp/.X11-unix/X##`
33	    getXuser;
34	    if [ x"$XAUTHORITY" != x"" ]; then
35		export DISPLAY=":$displaynum"
36		. /usr/share/acpi-support/screenblank
37	    fi
38	done
39    fi
40fi
41
42pm-suspend