No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
Este repositorio está archivado. Puede ver los archivos y clonarlo, pero no puede subir cambios o reportar incidencias ni pedir Pull Requests.

53 líneas
1.3KB

  1. #!/bin/bash
  2. # Example locker script -- demonstrates how to use the --transfer-sleep-lock
  3. # option with i3lock's forking mode to delay sleep until the screen is locked.
  4. ## CONFIGURATION ##############################################################
  5. # Options to pass to i3lock
  6. i3lock_options="-c 330033 -f"
  7. # Run before starting the locker
  8. pre_lock() {
  9. xset dpms force off
  10. return
  11. }
  12. # Run after the locker exits
  13. post_lock() {
  14. /usr/local/bin/screensaver-enable
  15. return
  16. }
  17. ###############################################################################
  18. pre_lock
  19. # We set a trap to kill the locker if we get killed, then start the locker and
  20. # wait for it to exit. The waiting is not that straightforward when the locker
  21. # forks, so we use this polling only if we have a sleep lock to deal with.
  22. if [[ -e /dev/fd/${XSS_SLEEP_LOCK_FD:--1} ]]; then
  23. kill_i3lock() {
  24. pkill -xu $EUID "$@" i3lock
  25. }
  26. trap kill_i3lock TERM INT
  27. # we have to make sure the locker does not inherit a copy of the lock fd
  28. i3lock $i3lock_options {XSS_SLEEP_LOCK_FD}<&-
  29. # now close our fd (only remaining copy) to indicate we're ready to sleep
  30. exec {XSS_SLEEP_LOCK_FD}<&-
  31. while kill_i3lock -0; do
  32. sleep 0.5
  33. done
  34. else
  35. trap 'kill %%' TERM INT
  36. i3lock -n $i3lock_options &
  37. wait
  38. fi
  39. post_lock