Created
January 15, 2022 02:51
-
-
Save lazerl0rd/2553de392ab8042726e53482b9b41e15 to your computer and use it in GitHub Desktop.
This script generates the Papiwaita icon theme, which is an icon theme based upon Adwaita with the addition of Papirus' application icons.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
if [[ $UID != 0 ]]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
if [[ $# -gt 1 ]]; then | |
echo "Only one argument may be used at a time. Use -h or --help to see valid arguments." | |
exit 1 | |
fi | |
copyFlag=false | |
case "$1" in | |
"-c" | "--copy") | |
copyFlag=true | |
;; | |
"-h" | "--help") | |
echo "This script generates the Papiwaita icon theme, which is an icon theme based upon Adwaita with the addition of Papirus' application icons." | |
echo "" | |
echo "The following are valid arguments:" | |
echo "" | |
echo "-c | --copy : Copy Papirus' icons over to Papiwaita rather than creating symbolic links." | |
echo "-h | --help : View this message." | |
exit 0 | |
;; | |
"*") | |
echo "The argument passed was unrecognised. Use --help to see valid arguments." | |
exit 1 | |
;; | |
esac | |
appSizes=("16" "22" "24" "32" "42" "48" "64" "84" "96" "128") | |
appSymSizes=("16" "22" "24" "32" "48" "64") | |
themeDir="/usr/share/icons" | |
# Adjust Umask | |
oldUmask="$(umask | tr -d "\n")" | |
umask "022" | |
# Remove Old Theme | |
rm -rf "$themeDir/Papiwaita" | |
# Create Directory Structure | |
for i in "${appSizes[@]}"; do | |
mkdir -p "$themeDir/Papiwaita/${i}x${i}/apps" | |
done | |
mkdir -p "$themeDir/Papiwaita/symbolic/apps" | |
# Create Symbolic Links for @2x Size Icons | |
for i in "${appSymSizes[@]}"; do | |
ln -rs "$themeDir/Papiwaita/${i}x${i}" "$themeDir/Papiwaita/${i}x${i}@2x" | |
done | |
# Create Symbolic Links for Papirus Icons | |
for i in "${appSizes[@]}"; do | |
for j in "$themeDir/Papirus/${i}x${i}/apps/"*; do | |
if $copyFlag; then | |
cp --preserve=links --reflink=auto "$j" "$themeDir/Papiwaita/${i}x${i}/apps/$(basename $j)" | |
else | |
ln -s "$j" "$themeDir/Papiwaita/${i}x${i}/apps/$(basename $j)" | |
fi | |
done | |
done | |
for i in "$themeDir/Papirus/symbolic/apps/"*; do | |
if $copyFlag; then | |
cp --preserve=links --reflink=auto "$i" "$themeDir/Papiwaita/symbolic/apps/$(basename $i)" | |
else | |
ln -s "$i" "$themeDir/Papiwaita/symbolic/apps/$(basename $i)" | |
fi | |
done | |
# Write Theme Index | |
cat > "$themeDir/Papiwaita/index.theme" << EOL | |
[Icon Theme] | |
Name=Papiwaita | |
Comment=Adwaita, but with Papirus' application icons. | |
Example=folder | |
Inherits=Adwaita,hicolor | |
Directories=16x16/apps,16x16@2x/apps,22x22/apps,22x22@2x/apps,24x24/apps,24x24@2x/apps,32x32/apps,32x32@2x/apps,42x42/apps,48x48/apps,48x48@2x/apps,64x64/apps,64x64@2x/apps,84x84/apps,96x96/apps,128x128/apps,symbolic/apps | |
[16x16/apps] | |
Context=Applications | |
Size=16 | |
Type=Fixed | |
[16x16@2x/apps] | |
Context=Applications | |
Size=16 | |
Scale=2 | |
Type=Fixed | |
[22x22/apps] | |
Context=Applications | |
Size=22 | |
Type=Fixed | |
[22x22@2x/apps] | |
Context=Applications | |
Size=22 | |
Scale=2 | |
Type=Fixed | |
[24x24/apps] | |
Context=Applications | |
Size=24 | |
Type=Fixed | |
[24x24@2x/apps] | |
Context=Applications | |
Size=24 | |
Scale=2 | |
Type=Fixed | |
[32x32/apps] | |
Context=Applications | |
Size=32 | |
Type=Fixed | |
[32x32@2x/apps] | |
Context=Applications | |
Size=32 | |
Scale=2 | |
Type=Fixed | |
[42x42/apps] | |
Context=Applications | |
Size=42 | |
Type=Fixed | |
[48x48/apps] | |
Context=Applications | |
Size=48 | |
Type=Fixed | |
[48x48@2x/apps] | |
Context=Applications | |
Size=48 | |
Scale=2 | |
Type=Fixed | |
[64x64/apps] | |
Context=Applications | |
Size=64 | |
Type=Fixed | |
[64x64@2x/apps] | |
Context=Applications | |
Size=64 | |
Scale=2 | |
Type=Fixed | |
[84x84/apps] | |
Context=Applications | |
Size=84 | |
Type=Fixed | |
[96x96/apps] | |
Context=Applications | |
Size=96 | |
Type=Fixed | |
[128x128/apps] | |
Context=Applications | |
Size=128 | |
MinSize=128 | |
MaxSize=512 | |
Type=Scalable | |
[symbolic/apps] | |
Context=Applications | |
Size=16 | |
MinSize=16 | |
MaxSize=512 | |
Type=Scalable | |
EOL | |
# Generate Theme Cache | |
if [[ -x $(which gtk-update-icon-cache) ]]; then | |
gtk-update-icon-cache -q "$themeDir/Papiwaita" | |
fi | |
# Restore Umask | |
umask "$oldUmask" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment