選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
このリポジトリはアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュや、課題・プルリクエストのオープンはできません。

i3lock.sh.j2 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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