You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.4KB

  1. #!/bin/bash
  2. #
  3. # bspwm-session
  4. #
  5. # This script is a session launcher for bspwm.
  6. # It is based on similar scripts included with Openbox.
  7. if [ -n "$1" ]; then
  8. echo "Usage: bspwm-session"
  9. echo
  10. exit 1
  11. fi
  12. # Multi-user support:
  13. state_prefix=${XDG_CACHE_HOME:-"$HOME/.cache"}
  14. mkdir -p "${state_prefix}"
  15. if [ ! -d "${state_prefix}" ]; then
  16. echo "bspwm-session: cache directory ‘${state_prefix}‘ is missing."
  17. echo
  18. exit 1
  19. elif [ ! -w "${state_prefix}" ]; then
  20. echo "bspwm-session: cache directory ‘${state_prefix}‘ is not writable."
  21. echo
  22. exit 1
  23. fi
  24. state_path=$(mktemp -d "${state_prefix}/bspwm-session.XXXXXX")
  25. if [ $? -ne 0 ]; then
  26. echo "bspwm-session: failed to create state directory ‘${state_path}‘."
  27. echo
  28. exit 1
  29. fi
  30. export BSPWM_SOCKET=${state_path}/bspwm-socket
  31. # Trap: make sure everything started in ~/.config/bspwm/autostart is
  32. # signalled when this script exits or dies. Also clean up $state_path.
  33. function on_exit {
  34. for child in $(jobs -p); do
  35. jobs -p | grep -q $child && kill $child
  36. done
  37. # Extra paranoia
  38. [[ -d "${state_path}" && -w "${state_path}" ]] && rm -rf -- "${state_path}"
  39. }
  40. trap on_exit EXIT SIGHUP SIGINT SIGTERM
  41. # Environment and autostart:
  42. source_these=(
  43. "/etc/profile"
  44. "${HOME}/.profile"
  45. "${XDG_CONFIG_HOME:-"$HOME/.config"}/bspwm/autostart"
  46. )
  47. for file in "${source_these[@]}"; do
  48. [ -r "${file}" ] && . "${file}"
  49. done
  50. # Launch sxhkd:
  51. sxhkd &
  52. # Launch bspwm:
  53. bspwm