Improving the script to report missing icons in icon packs.

This commit is contained in:
sergiotarxz 2022-02-06 03:15:37 +01:00
parent 3141acee69
commit 61f93b9e25
2 changed files with 73 additions and 24 deletions

63
functions.sh Normal file
View File

@ -0,0 +1,63 @@
#!/bin/bash
# This file is part of missing-icon-reporter
# and it's AGPLv3 licensed.
desktopsearch () {
cat /usr/share/applications/*.desktop | perl -ne '/^Icon=(?:-|\w|\.)+$/ and print' | sed s/Icon=//
}
iconsearch () {
local icon_pack=$1
if [ -z $icon_pack ]; then
echo "iconsearch requires a icon pack." 1>&2
exit 1;
fi
for icon in $(find ~/.icons/$icon_pack -name '*.png');
do
if [[ -f "${icon}" ]]; then
icon=$(basename ${icon} .png)
echo ${icon}
fi
done
}
compare_desktop_and_icons() {
local icon_pack=$1
if [ -z $icon_pack ]; then
echo "iconsearch requires a icon pack." 1>&2
exit 1;
fi
perl <(cat <<'EOF'
use v5.30.0;
use strict;
use warnings;
my $desktop_search_file = $ARGV[0];
my $icon_search_file = $ARGV[1];
my %desktop_relation;
open my $desktop_filehandle, '<', $desktop_search_file;
while (my $line = <$desktop_filehandle>) {
chomp $line;
$desktop_relation{$line} = 0;
}
close $desktop_filehandle;
open my $icon_filehandle, '<', $icon_search_file;
while (my $line = <$icon_filehandle>) {
chomp $line;
$desktop_relation{$line} = 1;
}
close $icon_filehandle;
for my $key (keys %desktop_relation) {
unless ($desktop_relation{$key}) {
say qq($key is missing);
}
}
EOF
) <(desktopsearch) <(iconsearch $icon_pack)
}

View File

@ -1,31 +1,17 @@
#! /bin/bash #! /bin/bash
# this file is part of missing-icon-reporter # This file is part of missing-icon-reporter
# and it's AGPLv3 licensed. # and it's AGPLv3 licensed.
desktopsearch () { script_path=$(dirname $0)
for DESKTOP in /usr/share/applications/*.desktop script_name=$(basename $0)
do icon_pack=$1
if [[ -f "${DESKTOP}" ]]; then
cat ${DESKTOP} | grep 'Icon=' | sed s/Icon=//
fi . "$script_path/functions.sh"
done
}
iconsearch () { if [ -z $icon_pack ]; then
for ICON in ~/.icons/aleta/*/*/*.png echo "$script_name requires a icon pack." 1>&2
do exit 1;
if [[ -f "${ICON}" ]]; then fi
N=$(basename ${ICON} .png)
echo ${N}
fi
done
}
desktopsearch | sort | uniq > /tmp/.missing-icon-reporter-desktopsearch.tmp
iconsearch | sort | uniq > /tmp/.missing-icon-reporter-iconsearch.tmp
cat /tmp/.missing-icon-reporter-desktopsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp | sort | uniq > /tmp/.missing-icon-reporter-comparisonsearch.tmp compare_desktop_and_icons $icon_pack;
cat /tmp/.missing-icon-reporter-comparisonsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp | sort | uniq
# diff --suppress-common-lines /tmp/.missing-icon-reporter-desktopsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp