logo

ultrasharp-cursor-theme

Precision and speed oriented cursor theme git clone https://anongit.hacktivis.me/git/ultrasharp-cursor-theme.git/

configure (3166B)


  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2023 Haelwenn (lanodan) Monnier <contact+ultrasharp@hacktivis.me>
  3. # SPDX-License-Identifier: BSD-3-Clause
  4. set -e
  5. usage() {
  6. cat <<'END'
  7. Usage: [variables] configure [variables]
  8. Variables:
  9. PREFIX=DIR
  10. DATADIR=DIR
  11. ICONDIR=DIR
  12. QUOTER=BIN
  13. XCURSORGEN=BIN
  14. Variables are set in the following order: Default, Environment, Arguments
  15. Dependencies: See README.md
  16. END
  17. }
  18. is_ok() {
  19. status="$?"
  20. if test $status -eq 0; then
  21. printf ' OK\n'
  22. else
  23. printf ' FAIL\n'
  24. fi
  25. return $status
  26. }
  27. required() {
  28. is_ok || exit 1
  29. }
  30. # defaults
  31. PREFIX="${PREFIX:-/usr/local}"
  32. XCURSORGEN="${XCURSORGEN:-xcursorgen}"
  33. QUOTER="${QUOTER:-quoter}"
  34. MAGICK="${MAGICK:-magick}"
  35. printf 'Checking %s command existance ...' "${QUOTER}"
  36. command -v "${QUOTER}" >/dev/null ; required
  37. arg0="$0"
  38. args="$("${QUOTER}" -- "$@" | sed 's;\$;$$;')"
  39. # Also allow variables through arguments
  40. for i; do
  41. case "$i" in
  42. -h|--help)
  43. usage
  44. exit 1
  45. ;;
  46. -*)
  47. printf "Unknown argument ‘%s’\n" "${i}"
  48. usage
  49. exit 1
  50. ;;
  51. *=*)
  52. # shellcheck disable=SC2163
  53. export "$i"
  54. shift
  55. ;;
  56. *)
  57. printf "Unknown argument ‘%s’\n" "${i}"
  58. usage
  59. exit 1
  60. ;;
  61. esac
  62. done
  63. # Fallback definitions for dirs, based on $PREFIX
  64. DATADIR=${DATADIR:-${PREFIX}/share}
  65. ICONDIR=${ICONDIR:-${DATADIR}/icons}
  66. ## System checks
  67. printf 'Checking %s command existance ...' "${XCURSORGEN}"
  68. command -v "${XCURSORGEN}" >/dev/null ; required
  69. printf 'Checking %s command existance ...' "${MAGICK}"
  70. command -v "${MAGICK}" >/dev/null ; required
  71. CURSORS='
  72. arrow
  73. context-menu
  74. crosshair
  75. grab
  76. grabbing
  77. move
  78. pointer
  79. text
  80. help
  81. row-resize
  82. col-resize
  83. e-resize
  84. w-resize
  85. n-resize
  86. s-resize
  87. nesw-resize
  88. nwse-resize
  89. nw-resize
  90. ne-resize
  91. sw-resize
  92. se-resize
  93. vertical-text
  94. zoom-in
  95. zoom-out
  96. '
  97. NAME=ultrasharp
  98. printf 'Writing to build.ninja ...'
  99. (
  100. cat <<EOF
  101. # Autogenerated by $arg0 $args
  102. THEMEDIR = ${ICONDIR}/${NAME}
  103. XCURSORGEN = ${XCURSORGEN}
  104. MAGICK = ${MAGICK}
  105. rule gen_config
  106. command = ${arg0} ${args}
  107. generator = 1
  108. build build.ninja: gen_config configure
  109. rule cursorgen
  110. command = \$XCURSORGEN \$in \$out
  111. rule install
  112. command = mkdir -p \$\${DESTDIR}\${THEMEDIR}/ && cp -r cursors \$\${DESTDIR}\${THEMEDIR}/ && cp index.theme \$\${DESTDIR}\${THEMEDIR}/
  113. rule flop
  114. command = \$MAGICK \$in -flop \$out
  115. rule flip
  116. command = \$MAGICK \$in -flip \$out
  117. rule 90rot
  118. command = \$MAGICK \$in -rotate 90 \$out
  119. build install: install | cursors
  120. build nesw-resize.png: flip nwse-resize.png
  121. build e-resize.png: flop w-resize.png
  122. build n-resize.png: 90rot w-resize.png
  123. build s-resize.png: flip n-resize.png
  124. build ne-resize.png: 90rot nw-resize.png
  125. build se-resize.png: 90rot ne-resize.png
  126. build sw-resize.png: 90rot se-resize.png
  127. build wait2.png: 90rot wait.png
  128. build wait3.png: 90rot wait2.png
  129. build wait4.png: 90rot wait3.png
  130. build cursors/wait: cursorgen wait.cfg | wait.png wait2.png wait3.png wait4.png
  131. EOF
  132. printf 'build all: phony'
  133. printf ' cursors/%s' ${CURSORS} wait
  134. printf '\n\n'
  135. printf 'default all\n'
  136. for cur in ${CURSORS}; do
  137. printf 'build cursors/%s: cursorgen %s.cfg | %s.png\n' $cur $cur $cur
  138. done
  139. ) >|build.ninja
  140. is_ok
  141. printf '\nDone, you can now run ninja or samu\n'