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.

67 lines
1.5KB

  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. export BSPWM_SOCKET=$HOME/.cache/bspwm-socket
  32. # Trap: make sure everything started in ~/.config/bspwm/autostart is
  33. # signalled when this script exits or dies. Also clean up $state_path.
  34. function on_exit {
  35. for child in $(jobs -p); do
  36. jobs -p | grep -q $child && kill $child
  37. done
  38. # Extra paranoia
  39. [[ -d "${state_path}" && -w "${state_path}" ]] && rm -rf -- "${state_path}"
  40. }
  41. trap on_exit EXIT SIGHUP SIGINT SIGTERM
  42. # Environment and autostart:
  43. source_these=(
  44. "/etc/profile"
  45. "${HOME}/.profile"
  46. "${XDG_CONFIG_HOME:-"$HOME/.config"}/bspwm/autostart"
  47. )
  48. for file in "${source_these[@]}"; do
  49. [ -r "${file}" ] && . "${file}"
  50. done
  51. # Launch sxhkd:
  52. sxhkd &
  53. # Launch bspwm:
  54. bspwm