blob: 07c3f41873cb32273bdecd0f1d663f63fbb5032f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/sh
# 20230728 bkw: Extract PNG icons from a mac .icns file, for use
# with a SlackBuilds.org script.
# They get written to a directory called icons/, with filenames like
# 32.png, 64.png, etc (the pixel size). After extracting them, you
# should 'git add icons/*' if you're using git (otherwise, include
# icons/ in your submission tarball).
# The SlackBuild should include code to install them; see
# syncterm.SlackBuild for an example. Don't forget to include a
# doinst.sh.
# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
# Feel free to use this as part of your own SlackBuild.
# Note that this script shouldn't be included in the package!
die() {
echo "$( basename $0 ): $@" 1>&2
exit 1
}
if [ "$1" = "" -o "$2" != "" ]; then
die "one argument required, path to *.icns file."
fi
if ! which icns2png &>/dev/null; then
die "icns2png not found in \$PATH. Install libicns."
fi
if [ -e icons ]; then
die "icons/ already exists, not overwriting."
fi
mkdir -p icons
cd icons || die "can't create or cd to icons/ dir."
icns2png -x -d 32 "$1" || die "can't extract any icons."
count=0
for png in *x32.png; do
[ -e $png ] || break
size="$( echo $png | cut -d_ -f2 | cut -dx -f1 )"
mv $png $size.png
: $(( count++ ))
done
if [ "$count" = "0" ]; then
rm -rf ../icons
die "failed to extract any icons."
fi
echo "extracted $count icons:"
ls
|