wok-next annotate gtk+/stuff/replace-icons-paper @ rev 20082
Up clementine
author | Xander Ziiryanoff <psychomaniak@xakep.ru> |
---|---|
date | Wed Oct 25 12:19:39 2017 +0200 (2017-10-25) |
parents | |
children |
rev | line source |
---|---|
al@19841 | 1 # Replace GTK+ stock icons by Paper icons |
al@19841 | 2 # in order to strip icon theme and save some space. |
al@19841 | 3 |
al@19841 | 4 |
al@19841 | 5 # Return shortest line |
al@19841 | 6 shortest_line() { |
al@19841 | 7 S=$1; shift |
al@19841 | 8 for L in $@; do |
al@19841 | 9 [ "${#L}" -lt "${#S}" ] && S="$L" |
al@19841 | 10 done |
al@19841 | 11 echo "$S" |
al@19841 | 12 } |
al@19841 | 13 |
al@19841 | 14 # Replace the same files by symlinks, $@ - list of identical files |
al@19841 | 15 make_symlinks() { |
al@19841 | 16 S=$(shortest_line $@) |
al@19841 | 17 for file in $@; do |
al@19841 | 18 [ "$S" != "$file" ] && ln -sf $S $file |
al@19841 | 19 done |
al@19841 | 20 } |
al@19841 | 21 |
al@19841 | 22 |
al@19841 | 23 echo -n "Replacing icons... " |
al@19841 | 24 |
al@19841 | 25 F=/usr/share/icons/Paper |
al@19841 | 26 |
al@19841 | 27 # copy icon |
al@19841 | 28 ci() { |
al@19841 | 29 icon=$(basename $1 .png) |
al@19841 | 30 size="$2" |
al@19841 | 31 sub='' |
al@19841 | 32 case $icon in |
al@19841 | 33 *-ltr) sub=${icon%-*};; |
al@19841 | 34 *-rtl) |
al@19841 | 35 case ${icon%-*} in |
al@19841 | 36 edit-redo) sub='edit-undo';; |
al@19841 | 37 edit-undo) sub='edit-redo';; |
al@19841 | 38 format-indent-less) sub='format-indent-more';; |
al@19841 | 39 format-indent-more) sub='format-indent-less';; |
al@19841 | 40 go-first) sub='go-last';; |
al@19841 | 41 go-last) sub='go-first';; |
al@19841 | 42 go-next) sub='go-previous';; |
al@19841 | 43 go-previous) sub='go-next';; |
al@19841 | 44 media-seek-backward) sub='media-seek-forward';; |
al@19841 | 45 media-seek-forward) sub='media-seek-backward';; |
al@19841 | 46 media-skip-backward) sub='media-skip-forward';; |
al@19841 | 47 media-skip-forward) sub='media-skip-backward';; |
al@19841 | 48 esac |
al@19841 | 49 sub="$sub $sub-ltr" |
al@19841 | 50 ;; |
al@19841 | 51 gtk-caps-lock-warning) sub='dialog-warning';; |
al@19841 | 52 gtk-color-picker) sub='color-picker';; |
al@19841 | 53 gtk-connect) sub='network-transmit-receive';; |
al@19841 | 54 gtk-disconnect) sub='network-offline';; |
al@19841 | 55 gtk-edit) sub='edit';; |
al@19841 | 56 gtk-font) sub='font-x-generic';; |
al@19841 | 57 gtk-page-setup) sub='document-page-setup';; |
al@19841 | 58 gtk-preferences) sub='preferences-desktop';; |
al@19841 | 59 gtk-select-color) sub='color-select';; |
al@19841 | 60 gtk-select-font) sub='font-select';; |
al@19841 | 61 gtk-apply) sub='object-select';; |
al@19841 | 62 gtk-no) sub='emblem-unreadable';; |
al@19841 | 63 gtk-yes) sub='emblem-default';; |
al@19841 | 64 gtk-ok) sub='object-select';; |
al@19841 | 65 esac |
al@19841 | 66 |
al@19841 | 67 found='' |
al@19841 | 68 for i in png svg; do |
al@19841 | 69 for j in actions apps categories devices emblems emotes mimetypes places status; do |
al@19841 | 70 for k in $icon $sub; do |
al@19841 | 71 if [ -f "$F/$size/$j/$k.$i" ]; then |
al@19841 | 72 found="$F/$size/$j/$k.$i" |
al@19841 | 73 break 3 |
al@19841 | 74 fi |
al@19841 | 75 done |
al@19841 | 76 done |
al@19841 | 77 done |
al@19841 | 78 case $found in |
al@19841 | 79 *.png) cp -f $found $1;; |
al@19841 | 80 *.svg) rm $1; rsvg-convert $found -o $1;; |
al@19841 | 81 esac |
al@19841 | 82 } |
al@19841 | 83 |
al@19841 | 84 cd $src/gtk/stock-icons/16; for a in $(ls); do ci $a 16x16; done |
al@19841 | 85 cd $src/gtk/stock-icons/20; for a in $(ls); do ci $a 16x16; done # yes, using 16x16 for 20 |
al@19841 | 86 cd $src/gtk/stock-icons/24; for a in $(ls); do ci $a 16x16; done # too |
al@19841 | 87 cd $src/gtk/stock-icons/32; for a in $(ls); do ci $a 32x32; done |
al@19841 | 88 cd $src/gtk/stock-icons/48; for a in $(ls); do ci $a 48x48; done |
al@19841 | 89 |
al@19841 | 90 echo "Done" |
al@19841 | 91 |
al@19841 | 92 for folder in 16 20 24 32 48; do |
al@19841 | 93 echo -n "Optimizing folder icons $folder... " |
al@19841 | 94 cd $src/gtk/stock-icons/$folder |
al@19841 | 95 for icon in ./*.png; do |
al@19841 | 96 pngquant -f --skip-if-larger --ext .png --speed 1 "$icon" |
al@19841 | 97 optipng -quiet -o7 -zm1-9 "$icon" |
al@19841 | 98 done |
al@19841 | 99 echo "Done" |
al@19841 | 100 done |
al@19841 | 101 |
al@19841 | 102 |
al@19841 | 103 # replace the same icons by symlinks |
al@19841 | 104 |
al@19841 | 105 MD5FILE=$(mktemp) |
al@19841 | 106 find $src/gtk/stock-icons -type f -exec md5sum '{}' \; | sort > $MD5FILE |
al@19841 | 107 for md in $(uniq -d -w32 $MD5FILE | cut -c1-32); do |
al@19841 | 108 make_symlinks $(grep $md $MD5FILE | cut -c35-) |
al@19841 | 109 done |
al@19841 | 110 rm "$MD5FILE" |
al@19841 | 111 # make all symlinks relative |
al@19841 | 112 symlinks -crs $src/gtk/stock-icons >/dev/null 2>&1 |
al@19841 | 113 |
al@19841 | 114 |
al@19841 | 115 |
al@19841 | 116 # missing icons: |
al@19841 | 117 # 16, 24 |
al@19841 | 118 # ============================================================================== |
al@19841 | 119 # gtk-convert |
al@19841 | 120 # gtk-index |
al@19841 | 121 # gtk-orientation-landscape |
al@19841 | 122 # gtk-orientation-portrait |
al@19841 | 123 # gtk-orientation-reverse-landscape |
al@19841 | 124 # gtk-orientation-reverse-portrait |
al@19841 | 125 # gtk-undelete-ltr |
al@19841 | 126 # gtk-undelete-rtl |
al@19841 | 127 # printer-paused |
al@19841 | 128 # printer-warning |
al@19841 | 129 # 32 |
al@19841 | 130 # ============================================================================== |
al@19841 | 131 # gtk-dnd |
al@19841 | 132 # gtk-dnd-multiple |