|
| 1 | +#!/bin/bash |
| 2 | +# A script for preparing binaries of Apple Cursors, created by Abdulkaiz Khatri. |
| 3 | + |
| 4 | +version="v2.0.1" |
| 5 | + |
| 6 | +error() ( |
| 7 | + set -o pipefail |
| 8 | + "$@" 2> >(sed $'s,.*,\e[31m&\e[m,' >&2) |
| 9 | +) |
| 10 | + |
| 11 | +get_config_file() { |
| 12 | + local key="${1}" |
| 13 | + local cfg_file="build.toml" |
| 14 | + |
| 15 | + if [[ $key == *"Right"* ]]; then |
| 16 | + cfg_file="build.right.toml" |
| 17 | + fi |
| 18 | + |
| 19 | + echo $cfg_file |
| 20 | +} |
| 21 | + |
| 22 | +with_version() { |
| 23 | + local comment="${1}" |
| 24 | + echo "$comment ($version)." |
| 25 | +} |
| 26 | + |
| 27 | +if ! type -p ctgen >/dev/null; then |
| 28 | + error ctgen |
| 29 | + exit 127 # exit program with "command not found" error code |
| 30 | +fi |
| 31 | + |
| 32 | +declare -A names |
| 33 | +names["macOS"]=$(with_version "macOS cursors") |
| 34 | +names["macOS-White"]=$(with_version "White macOS cursors") |
| 35 | + |
| 36 | +# Cleanup old builds |
| 37 | +rm -rf themes bin |
| 38 | + |
| 39 | +# Building Apple XCursor binaries |
| 40 | +for key in "${!names[@]}"; do |
| 41 | + comment="${names[$key]}" |
| 42 | + cfg=$(get_config_file key) |
| 43 | + |
| 44 | + ctgen "$cfg" -p x11 -d "bitmaps/$key" -n "$key" -c "$comment" & |
| 45 | + PID=$! |
| 46 | + wait $PID |
| 47 | +done |
| 48 | + |
| 49 | +# Building Bibata Windows binaries |
| 50 | +for key in "${!names[@]}"; do |
| 51 | + comment="${names[$key]}" |
| 52 | + cfg=$(get_config_file key) |
| 53 | + |
| 54 | + ctgen "$cfg" -p windows -s 16 -d "bitmaps/$key" -n "$key-Small" -c "$comment" & |
| 55 | + ctgen "$cfg" -p windows -s 24 -d "bitmaps/$key" -n "$key-Regular" -c "$comment" & |
| 56 | + ctgen "$cfg" -p windows -s 32 -d "bitmaps/$key" -n "$key-Large" -c "$comment" & |
| 57 | + ctgen "$cfg" -p windows -s 48 -d "bitmaps/$key" -n "$key-Extra-Large" -c "$comment" & |
| 58 | + PID=$! |
| 59 | + wait $PID |
| 60 | +done |
| 61 | + |
| 62 | +# Compressing Binaries |
| 63 | +mkdir -p bin |
| 64 | +cd themes || exit |
| 65 | + |
| 66 | +for key in "${!names[@]}"; do |
| 67 | + tar -cJvf "../bin/${key}.tar.xz" "${key}" & |
| 68 | + PID=$! |
| 69 | + wait $PID |
| 70 | +done |
| 71 | + |
| 72 | +# Compressing Bibata.tar.xz |
| 73 | +cp ../LICENSE . |
| 74 | +tar -cJvf "../bin/macOS.tar.xz" --exclude="*-Windows" . & |
| 75 | +PID=$! |
| 76 | +wait $PID |
| 77 | + |
| 78 | +# Compressing Bibata-*-Windows |
| 79 | +for key in "${!names[@]}"; do |
| 80 | + zip -rv "../bin/${key}-Windows.zip" "${key}-Small-Windows" "${key}-Regular-Windows" "${key}-Large-Windows" "${key}-Extra-Large-Windows" & |
| 81 | + PID=$! |
| 82 | + wait $PID |
| 83 | +done |
| 84 | + |
| 85 | +cd .. |
| 86 | + |
| 87 | +# Copying License File for 'bitmaps' |
| 88 | +cp LICENSE bitmaps/ |
| 89 | +zip -rv bin/bitmaps.zip bitmaps |
0 commit comments