Skip to content

Commit

Permalink
Merge pull request #1693 from autinerd/freedesktop-theme
Browse files Browse the repository at this point in the history
freedesktop-theme: new mapping system, icons are now only generated for symbolic and scalable.
  • Loading branch information
Donnnno authored Sep 9, 2023
2 parents f52d0b3 + 188d7a5 commit c8f3bc9
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 918 deletions.
4 changes: 3 additions & 1 deletion freedesktop-theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ In KDE, you can select the icon theme in the System Settings > Icons.

## Mapping the icons

The `mappings.txt` contains the mappings of the arcticons in the format `<Arcticon icon name>,<Freedesktop icon path>`
The `mappings.txt` contains the mappings of the arcticons in the format `<Arcticon icon name>,<Freedesktop icon path>:<Freedesktop icon path>`

When one Arcticons icon is used for multiple icons in the freedesktop theme, the paths are separated by a `:`.

To contribute, you need to look the path of the priginal icons. Application icons are in `/usr/share/icons/hicolor/<icon size>/apps`, while system icons are covered by the other icon themes. (In GNOME, the default is Adwaita; For KDE Plasma, it's Breeze) The icons are either in the `<icon size>/<icon category>`, or in `<icon category>/<icon size>` subfolders.

Expand Down
50 changes: 29 additions & 21 deletions freedesktop-theme/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,41 +33,49 @@ set -euo pipefail
style=${1:-white}
line_weight=${2:-1.0}

sizes="32 48 64 96 128 256 512"
rm -r ./arcticons/ 2> /dev/null || true

rm -r ./arcticons/*/** 2> /dev/null || true
dest_root="./arcticons/scalable"

for size in $sizes; do
factor=$(awk "BEGIN { print 48 / $size }")
dest_root="./arcticons/${size}x${size}"
for line in $(cat mapping.txt); do
echo $line
src=$(echo "$line" | cut -d, -f1)
dests=( `echo "$line" | cut -d, -f2 | tr ':' ' '` )
dest=${dests[0]}

for line in $(cat mapping.txt); do
src=$(echo "$line" | cut -d, -f1)
dest=$(echo "$line" | cut -d, -f2)

mkdir -p "$dest_root/$(dirname "$dest")"
cp -v "../icons/$style/$src.svg" "$dest_root/$dest.svg" || continue
mkdir -p "$dest_root/$(dirname "$dest")"
cp -v "../icons/$style/$src.svg" "$dest_root/$dest.svg" || continue

grep -v 'stroke-width' "$dest_root/$dest.svg" > /dev/null && sed -i 's/\(stroke:[^;]\+\)/\1;stroke-width:1px/g' "$dest_root/$dest.svg"
awk -i inplace -F 'stroke-width:|px' "{ print \$1 \"stroke-width:\" (\$2 * $line_weight * $factor) \"px\" \$3; }" "$dest_root/$dest.svg"
done
grep -v 'stroke-width' "$dest_root/$dest.svg" > /dev/null && sed -i 's/\(stroke:[^;]\+\)/\1;stroke-width:1px/g' "$dest_root/$dest.svg"
awk -i inplace -F 'stroke-width:|px' "{ print \$1 \"stroke-width:\" (\$2 * $line_weight) \"px\" \$3; }" "$dest_root/$dest.svg"

rm "${dest_root}@2" 2> /dev/null || true
ln -s "${size}x${size}" "${dest_root}@2"
rm "${dest_root}@3" 2> /dev/null || true
ln -s "${size}x${size}" "${dest_root}@3"
if [ ${#dests[@]} -gt 1 ]; then
for i in $(seq 1 $((${#dests[@]}-1))); do
mkdir -p "$dest_root/$(dirname "${dests[$i]}")"
ln -vs "../${dests[0]}.svg" "$dest_root/${dests[$i]}.svg"
done
fi
done

if type inkscape; then
for line in $(cat mapping.txt); do
echo $line
src=$(echo "$line" | cut -d, -f1)
dests=( `echo "$line" | cut -d, -f2 | tr ':' ' '` )
dest=${dests[0]}
dest_root="./arcticons/symbolic"
src_root="./arcticons/48x48"
dest=$(echo "$line" | cut -d, -f2)
src_root="./arcticons/scalable"

mkdir -p "$dest_root/$(dirname "$dest")"

inkscape --actions="select-all;object-stroke-to-path" --export-filename="$dest_root/$dest-symbolic.svg" "$src_root/$dest.svg" || true
rm $src_root/$dest*.0.svg || true

if [ ${#dests[@]} -gt 1 ]; then
for i in $(seq 1 $((${#dests[@]}-1))); do
mkdir -p "$dest_root/$(dirname "${dests[$i]}")"
ln -vs "../${dests[0]}-symbolic.svg" "$dest_root/${dests[$i]}-symbolic.svg"
done
fi
done
else echo "Inkscape not found, skipping creating symbolic icons"
fi
Expand Down
Loading

0 comments on commit c8f3bc9

Please sign in to comment.