install-all 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #! /bin/bash
  2. #
  3. # install-all
  4. # Part of ComixCursors, a desktop cursor theme.
  5. #
  6. # Copyright © 2010–2013 Ben Finney <ben+opendesktop@benfinney.id.au>
  7. # Copyright © 2006–2013 Jens Luetkens <j.luetkens@limitland.de>
  8. #
  9. # This work is free software: you can redistribute it and/or modify it
  10. # under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This work is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. # General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this work. If not, see <http://www.gnu.org/licenses/>.
  21. # Build and install all the ComixCursors themes.
  22. themename_stem="ComixCursors"
  23. configfile_dir="${themename_stem}Configs"
  24. configfile_template_name="Custom"
  25. bindir="$(dirname $0)"/bin
  26. # Set the ICONSDIR destination to a default (if not already set).
  27. ICONSDIR=${ICONSDIR:-~/.icons}
  28. export ICONSDIR
  29. # We want to use cursors with multiple sizes combined.
  30. # The script check wether MULTISIZE is exported at all, so don't export
  31. # MULTISIZE if you want distinct cursor sizes, comment it out here or
  32. # unset it from the shell.
  33. export MULTISIZE=true
  34. # argument processing and usage
  35. function show_usage_message {
  36. cat <<_EOT_
  37. Usage: $0 [option]
  38. Install the ComixCursors mouse theme.
  39. Options:
  40. -h: Display this help text, then exit.
  41. -u: Uninstall the ComixCursors mouse theme.
  42. -v: Be verbose.
  43. _EOT_
  44. }
  45. while getopts ":uhv" opt; do
  46. case $opt in
  47. h)
  48. show_usage_message
  49. exit
  50. ;;
  51. u)
  52. UNINSTALL=true
  53. ;;
  54. v)
  55. export VERBOSE=true
  56. ;;
  57. *)
  58. printf "Unexpected option: -%s\n" "$OPTARG" >&2
  59. show_usage_message
  60. exit 2
  61. ;;
  62. esac
  63. done
  64. function build_theme {
  65. # Build the cursors for a particular theme.
  66. THEMENAME="$1"
  67. export THEMENAME
  68. if [ $UNINSTALL ]; then
  69. make uninstall
  70. else
  71. if [ ${MULTISIZE} ] ; then
  72. printf "\nBuilding \"${THEMENAME}${THEMEOPTIONS}${THEMEINCLUDE}\" (multisize)\n"
  73. "${bindir}"/build-cursors
  74. if [ $VERBOSE ] ; then
  75. make
  76. make install
  77. else
  78. make -s
  79. make -s install
  80. fi
  81. else
  82. # build one theme for each configured size
  83. configfile="${configfile_dir}/${THEMENAME}.CONFIG"
  84. source "${configfile}"
  85. for SIZENAMES in ${SIZES[@]} ; do
  86. export SIZENAME="-${SIZENAMES%%=*}"
  87. export CURSORSIZE=${SIZENAMES##*=}
  88. printf "\nBuilding \"${THEMENAME}${THEMEOPTIONS}${THEMEINCLUDE}${SIZENAME}\"\n"
  89. "${bindir}"/build-cursors
  90. if [ $VERBOSE ] ; then
  91. make
  92. make install
  93. else
  94. make -s
  95. make -s install
  96. fi
  97. done
  98. fi
  99. fi
  100. }
  101. function build_include_theme {
  102. themename="$1"
  103. # build the right-handed version
  104. export ORIENTATION="RightHanded"
  105. export THEMEOPTIONS=""
  106. build_theme "$themename"
  107. # also build the left-handed version
  108. export ORIENTATION="LeftHanded"
  109. export THEMEOPTIONS="-LH"
  110. build_theme "$themename"
  111. }
  112. for configfile in "${configfile_dir}"/*.CONFIG ; do
  113. # Each config file represents a theme to be built.
  114. configfile_name=$(basename "$configfile")
  115. themename="${configfile_name%.CONFIG}"
  116. if [ "$themename" == "$configfile_template_name" ]; then
  117. # The template isn't a theme we want to build.
  118. continue
  119. fi
  120. unset THEMEINCLUDE
  121. build_include_theme "$themename"
  122. for includefile in "${configfile_dir}"/*.INCLUDE ; do
  123. includefile_name=$(basename "$includefile")
  124. export THEMEINCLUDE="-${includefile_name%.INCLUDE}"
  125. build_include_theme "$themename"
  126. done
  127. done
  128. exit 0