logo

ultrasharp-cursor-theme

Precision and speed oriented cursor theme

configure (3152B)


  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. move
  76. text
  77. pointer
  78. help
  79. row-resize
  80. col-resize
  81. e-resize
  82. w-resize
  83. n-resize
  84. s-resize
  85. nesw-resize
  86. nwse-resize
  87. nw-resize
  88. ne-resize
  89. sw-resize
  90. se-resize
  91. vertical-text
  92. zoom-in
  93. zoom-out
  94. '
  95. NAME=ultrasharp
  96. printf 'Writing to build.ninja ...'
  97. (
  98. cat <<EOF
  99. # Autogenerated by $arg0 $args
  100. THEMEDIR = ${ICONDIR}/${NAME}
  101. XCURSORGEN = ${XCURSORGEN}
  102. MAGICK = ${MAGICK}
  103. rule gen_config
  104. command = ${arg0} ${args}
  105. generator = 1
  106. build build.ninja: gen_config configure
  107. rule cursorgen
  108. command = \$XCURSORGEN \$in \$out
  109. rule install
  110. command = mkdir -p \$\${DESTDIR}\${THEMEDIR}/ && cp -r cursors \$\${DESTDIR}\${THEMEDIR}/ && cp index.theme \$\${DESTDIR}\${THEMEDIR}/
  111. rule flop
  112. command = \$MAGICK \$in -flop \$out
  113. rule flip
  114. command = \$MAGICK \$in -flip \$out
  115. rule 90rot
  116. command = \$MAGICK \$in -rotate 90 \$out
  117. build install: install | cursors
  118. build nesw-resize.png: flip nwse-resize.png
  119. build e-resize.png: flop w-resize.png
  120. build n-resize.png: 90rot w-resize.png
  121. build s-resize.png: flip n-resize.png
  122. build ne-resize.png: 90rot nw-resize.png
  123. build se-resize.png: 90rot ne-resize.png
  124. build sw-resize.png: 90rot se-resize.png
  125. build wait2.png: 90rot wait.png
  126. build wait3.png: 90rot wait2.png
  127. build wait4.png: 90rot wait3.png
  128. build cursors/wait: cursorgen wait.cfg | wait.png wait2.png wait3.png wait4.png
  129. EOF
  130. printf 'build all: phony'
  131. printf ' cursors/%s' ${CURSORS} wait
  132. printf '\n\n'
  133. printf 'default all\n'
  134. for cur in ${CURSORS}; do
  135. printf 'build cursors/%s: cursorgen %s.cfg | %s.png\n' $cur $cur $cur
  136. done
  137. ) >|build.ninja
  138. is_ok
  139. printf '\nDone, you can now run ninja or samu\n'