Improving the script to report missing icons in icon packs.
This commit is contained in:
parent
3141acee69
commit
61f93b9e25
63
functions.sh
Normal file
63
functions.sh
Normal 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)
|
||||||
|
}
|
34
missing.sh
34
missing.sh
@ -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
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
iconsearch () {
|
. "$script_path/functions.sh"
|
||||||
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
|
|
||||||
|
|
||||||
cat /tmp/.missing-icon-reporter-desktopsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp | sort | uniq > /tmp/.missing-icon-reporter-comparisonsearch.tmp
|
if [ -z $icon_pack ]; then
|
||||||
|
echo "$script_name requires a icon pack." 1>&2
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
cat /tmp/.missing-icon-reporter-comparisonsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp | sort | uniq
|
compare_desktop_and_icons $icon_pack;
|
||||||
# diff --suppress-common-lines /tmp/.missing-icon-reporter-desktopsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp
|
|
||||||
|
Loading…
Reference in New Issue
Block a user