Xsession 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. #
  3. # $OpenBSD: Xsession.in,v 1.1 2017/07/26 21:14:54 matthieu Exp $
  4. prefix="/usr/X11R6"
  5. exec_prefix="${prefix}"
  6. # redirect errors to a file in user's home directory if we can
  7. errfile="$HOME/.xsession-errors"
  8. if ( umask 077 && cp /dev/null "$errfile" 2> /dev/null )
  9. then
  10. exec > "$errfile" 2>&1
  11. else
  12. for errfile in "${TMPDIR-/tmp}/xses-$USER" "/tmp/xses-$USER"
  13. do
  14. if ef="$( umask 077 && mktemp "$errfile.XXXXXX" 2> /dev/null)"
  15. then
  16. exec > "$ef" 2>&1
  17. mv "$ef" "$errfile" 2> /dev/null
  18. break
  19. fi
  20. done
  21. fi
  22. # if we have private ssh key(s), start ssh-agent and add the key(s)
  23. id1=$HOME/.ssh/identity
  24. id2=$HOME/.ssh/id_dsa
  25. id3=$HOME/.ssh/id_rsa
  26. id4=$HOME/.ssh/id_ecdsa
  27. id5=$HOME/.ssh/id_ed25519
  28. if [ -z "$SSH_AGENT_PID" ];
  29. then
  30. if [ -x /usr/bin/ssh-agent ] && [ -f $id1 -o -f $id2 -o -f $id3 -o -f $id4 -o -f $id5 ];
  31. then
  32. eval `ssh-agent -s`
  33. ssh-add < /dev/null
  34. fi
  35. fi
  36. do_exit() {
  37. if [ "$SSH_AGENT_PID" ]; then
  38. ssh-add -D < /dev/null
  39. eval `ssh-agent -s -k`
  40. fi
  41. exit
  42. }
  43. case $# in
  44. 1)
  45. case $1 in
  46. failsafe)
  47. ${exec_prefix}/bin/xterm -geometry 80x24-0-0
  48. do_exit
  49. ;;
  50. esac
  51. esac
  52. # The startup script is not intended to have arguments.
  53. startup=$HOME/.xsession
  54. resources=$HOME/.Xresources
  55. if [ -s "$startup" ]; then
  56. if [ -x "$startup" ]; then
  57. "$startup"
  58. else
  59. /bin/sh "$startup"
  60. fi
  61. else
  62. if [ -f "$resources" ]; then
  63. /usr/X11R6/bin/xrdb -load "$resources"
  64. fi
  65. ${exec_prefix}/bin/xterm &
  66. ${exec_prefix}/bin/fvwm
  67. fi
  68. do_exit