build.sh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #!/bin/bash
  2. # Open initial output.
  3. # Prefer konsole if its there, otherwise fall back to xterminal.
  4. #tty -s; if [ $? -ne 0 ]; then
  5. # if command -v konsole &>/dev/null; then
  6. # konsole -e "$0"; exit;
  7. # else
  8. # xterm -e "$0"; exit;
  9. # fi
  10. #fi
  11. cd "$( dirname "${BASH_SOURCE[0]}" )"
  12. RAWSVG="src/cursors.svg"
  13. INDEX="src/index.theme"
  14. ALIASES="src/cursorList"
  15. echo -ne "Checking Requirements...\\r"
  16. if [ ! -f $RAWSVG ] ; then
  17. echo -e "\\nFAIL: '$RAWSVG' missing in /src"
  18. exit 1
  19. fi
  20. if [ ! -f $INDEX ] ; then
  21. echo -e "\\nFAIL: '$INDEX' missing in /src"
  22. exit 1
  23. fi
  24. if ! type "inkscape" > /dev/null ; then
  25. echo -e "\\nFAIL: inkscape must be installed"
  26. exit 1
  27. fi
  28. if ! type "xcursorgen" > /dev/null ; then
  29. echo -e "\\nFAIL: xcursorgen must be installed"
  30. exit 1
  31. fi
  32. echo -e "Checking Requirements... DONE"
  33. echo -ne "Making Folders... $BASENAME\\r"
  34. DIR2X="build/x2"
  35. DIR1_5X="build/x1_5"
  36. DIR1X="build/x1"
  37. OUTPUT="$(grep --only-matching --perl-regex "(?<=Name\=).*$" $INDEX)"
  38. OUTPUT=${OUTPUT// /_}
  39. mkdir -p "$DIR2X"
  40. mkdir -p "$DIR1_5X"
  41. mkdir -p "$DIR1X"
  42. mkdir -p "$OUTPUT/cursors"
  43. echo 'Making Folders... DONE';
  44. for CUR in src/config/*.cursor; do
  45. BASENAME=$CUR
  46. BASENAME=${BASENAME##*/}
  47. BASENAME=${BASENAME%.*}
  48. echo -ne "\033[0KGenerating simple cursor pixmaps... $BASENAME\\r"
  49. if [ "$DIR1X/$BASENAME.png" -ot $RAWSVG ] ; then
  50. inkscape -i $BASENAME -d 90 $RAWSVG --export-background-opacity=0 --export-filename="$DIR1X/$BASENAME.png" > /dev/null
  51. fi
  52. if [ "$DIR1_5X/$BASENAME.png" -ot $RAWSVG ] ; then
  53. inkscape -i $BASENAME -d 135 $RAWSVG --export-background-opacity=0 --export-filename="$DIR1_5X/$BASENAME.png" > /dev/null
  54. fi
  55. if [ "$DIR2X/$BASENAME.png" -ot $RAWSVG ] ; then
  56. inkscape -i $BASENAME -d 180 $RAWSVG --export-background-opacity=0 --export-filename="$DIR2X/$BASENAME.png" > /dev/null
  57. fi
  58. done
  59. echo -e "\033[0KGenerating simple cursor pixmaps... DONE"
  60. for i in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  61. do
  62. echo -ne "\033[0KGenerating animated cursor pixmaps... $i / 23 \\r"
  63. if [ "$DIR1X/progress-$i.png" -ot $RAWSVG ] ; then
  64. inkscape -i progress-$i -d 90 $RAWSVG --export-background-opacity=0 --export-filename="$DIR1X/progress-$i.png" > /dev/null
  65. fi
  66. if [ "$DIR1_5X/progress-$i.png" -ot $RAWSVG ] ; then
  67. inkscape -i progress-$i -d 135 $RAWSVG --export-background-opacity=0 --export-filename="$DIR1_5X/progress-$i.png" > /dev/null
  68. fi
  69. if [ "$DIR2X/progress-$i.png" -ot $RAWSVG ] ; then
  70. inkscape -i progress-$i -d 180 $RAWSVG --export-background-opacity=0 --export-filename="$DIR2X/progress-$i.png" > /dev/null
  71. fi
  72. if [ "$DIR1X/wait-$i.png" -ot $RAWSVG ] ; then
  73. inkscape -i wait-$i -d 90 $RAWSVG --export-background-opacity=0 --export-filename="$DIR1X/wait-$i.png" > /dev/null
  74. fi
  75. if [ "$DIR1_5X/wait-$i.png" -ot $RAWSVG ] ; then
  76. inkscape -i wait-$i -d 135 $RAWSVG --export-background-opacity=0 --export-filename="$DIR1_5X/wait-$i.png" > /dev/null
  77. fi
  78. if [ "$DIR2X/wait-$i.png" -ot $RAWSVG ] ; then
  79. inkscape -i wait-$i -d 180 $RAWSVG --export-background-opacity=0 --export-filename="$DIR2X/wait-$i.png" > /dev/null
  80. fi
  81. done
  82. echo -e "\033[0KGenerating animated cursor pixmaps... DONE"
  83. echo -ne "Generating cursor theme...\\r"
  84. for CUR in src/config/*.cursor; do
  85. BASENAME=$CUR
  86. BASENAME=${BASENAME##*/}
  87. BASENAME=${BASENAME%.*}
  88. ERR="$( xcursorgen -p build "$CUR" "$OUTPUT/cursors/$BASENAME" 2>&1 )"
  89. if [[ "$?" -ne "0" ]]; then
  90. echo "FAIL: $CUR $ERR"
  91. fi
  92. done
  93. echo -e "Generating cursor theme... DONE"
  94. echo -ne "Generating shortcuts...\\r"
  95. while read ALIAS ; do
  96. FROM=${ALIAS% *}
  97. TO=${ALIAS#* }
  98. if [ -e "$OUTPUT/cursors/$FROM" ] ; then
  99. continue
  100. fi
  101. ln -s "$TO" "$OUTPUT/cursors/$FROM"
  102. done < $ALIASES
  103. echo -e "\033[0KGenerating shortcuts... DONE"
  104. echo -ne "Copying Theme Index...\\r"
  105. if ! [ -e "$OUTPUT/$INDEX" ] ; then
  106. cp $INDEX "$OUTPUT/index.theme"
  107. fi
  108. echo -e "\033[0KCopying Theme Index... DONE"
  109. echo "COMPLETE!"