profile 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # vim: ft=sh:
  2. # shellcheck shell=sh
  3. # shellcheck source=/dev/null
  4. # shellcheck disable=3043,1090
  5. # load env
  6. __env=''
  7. for __env in ~/.nix-profile/etc/profile.d/nix.sh ~/.config/env; do
  8. [ -f "${__env}" ] && . "${__env}"
  9. done
  10. unset __env
  11. # start user services
  12. command -v s6-user-init >/dev/null && {
  13. # shellcheck disable=3030,2190,2206,2296
  14. {
  15. __ppid="${$}"
  16. __checked_disown() {
  17. if type disown 1>/dev/null; then
  18. # shellcheck disable=3044
  19. disown
  20. fi
  21. }
  22. # shellcheck disable=3044
  23. [ -n "${ZSH_VERSION}" ] && {
  24. declare -hA __old_options
  25. __old_options=(${(kv)options})
  26. setopt no_notify no_monitor
  27. }
  28. # shellcheck disable=2016
  29. ppid="${__ppid}" \
  30. pd "${__ppid}" \
  31. 'exec s6-user-init stop "${ppid:?}"' \
  32. & __checked_disown
  33. s6-user-init start "${__ppid:?}" & __checked_disown
  34. [ -n "${ZSH_VERSION}" ] && {
  35. # shellcheck disable=2034
  36. options=(${(kv)__old_options})
  37. unset __old_options
  38. }
  39. unset -f __checked_disown
  40. unset __ppid
  41. } 1>/dev/null 2>/dev/null
  42. }
  43. # if on first TTY then start X
  44. [ "${TTY:-$(tty)}" = /dev/tty1 ] && {
  45. xlog="${TMPDIR:-/tmp}/x.log"
  46. {
  47. SX_CLIENT_STOP_CMD="s6-x11-init stop ${$}" \
  48. exec sx start \
  49. dbus-launch --exit-with-x11 s6-x11-init start "${$}"
  50. } 1>>"${xlog}" 2>>"${xlog}"
  51. }