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