constants 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. #
  3. # constants: some constant values needed by all library status scripts
  4. #
  5. # Copyright (C) 2011-2014 Dustin Kirkland
  6. #
  7. # Authors: Dustin Kirkland <kirkland@byobu.org>
  8. #
  9. # This program is free software: you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, version 3 of the License.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. PKG="byobu"
  21. . "${BYOBU_PREFIX}/lib/${PKG}/include/icons"
  22. . "${BYOBU_PREFIX}/lib/${PKG}/include/colors"
  23. PCT="%"
  24. # Support two different backends (screen/tmux)
  25. if [ -z "$BYOBU_BACKEND" ]; then
  26. [ -r "/etc/byobu/backend" ] && . "/etc/byobu/backend"
  27. [ -r "$BYOBU_CONFIG_DIR/backend" ] && . "$BYOBU_CONFIG_DIR/backend"
  28. fi
  29. case "$BYOBU_BACKEND" in
  30. tmux)
  31. export BYOBU_BACKEND
  32. BYOBU_ARG_VERSION="-V"
  33. ESC=
  34. ;;
  35. screen)
  36. export BYOBU_BACKEND
  37. BYOBU_ARG_VERSION="-v"
  38. ESC="\005"
  39. ;;
  40. esac
  41. # MacOS Support
  42. eval $BYOBU_TEST gsed >/dev/null 2>&1 && export BYOBU_SED="gsed" || export BYOBU_SED="sed"
  43. eval $BYOBU_TEST greadlink >/dev/null 2>&1 && export BYOBU_READLINK="greadlink" || export BYOBU_READLINK="readlink"
  44. eval $BYOBU_TEST sensible-pager >/dev/null 2>&1 && export BYOBU_PAGER="sensible-pager" || export BYOBU_PAGER="less"
  45. eval $BYOBU_TEST sensible-editor >/dev/null 2>&1 && export BYOBU_EDITOR="sensible-editor" || export BYOBU_EDITOR="$EDITOR"
  46. eval $BYOBU_TEST "$BYOBU_EDITOR" >/dev/null 2>&1 || export BYOBU_EDITOR="vim"
  47. # Check sed's follow-symlinks feature
  48. $BYOBU_SED --follow-symlinks "s///" /dev/null 2>/dev/null && BYOBU_SED_INLINE="$BYOBU_SED -i --follow-symlinks" || BYOBU_SED_INLINE="$BYOBU_SED -i"
  49. # Determine if we have ulimit support
  50. eval $BYOBU_TEST ulimit >/dev/null 2>&1 && export BYOBU_ULIMIT="ulimit" || export BYOBU_ULIMIT="false"
  51. # Find a suitable python interpreter, if undefined
  52. if [ -z "$BYOBU_PYTHON" ]; then
  53. if python3 -c "import snack" >/dev/null 2>&1; then
  54. export BYOBU_PYTHON="python3"
  55. elif python2 -c "import snack" >/dev/null 2>&1; then
  56. export BYOBU_PYTHON="python2"
  57. elif python -c "import snack" >/dev/null 2>&1; then
  58. export BYOBU_PYTHON="python"
  59. fi
  60. fi
  61. export BYOBU_WINDOW_NAME="-"
  62. export BYOBU_DATE="%Y-%m-%d "
  63. export BYOBU_TIME="%H:%M:%S"