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