Merge pull request 'Improving the script to report missing icons in icon packs.' (#1) from sergiotarxz/IconToaster:master into master
Reviewed-on: https://gitea.sergiotarxz.freemyip.com/germedeb/IconToaster/pulls/1
This commit is contained in:
commit
7b8e851571
105
functions.sh
Normal file
105
functions.sh
Normal file
@ -0,0 +1,105 @@
|
||||
#!/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;
|
||||
|
||||
use Term::ANSIColor;
|
||||
|
||||
$SIG{INT} = sub {
|
||||
color_wrapper('reset');
|
||||
};
|
||||
|
||||
sub color_wrapper {
|
||||
print color(shift) if -t STDOUT || $ENV{TOASTER_COLOR};
|
||||
}
|
||||
|
||||
color_wrapper('yellow');
|
||||
say 'This is the Toasters Icon Pack Missing Icons Tool';
|
||||
color_wrapper('reset');
|
||||
|
||||
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;
|
||||
|
||||
color_wrapper('red');
|
||||
say << 'EOS';
|
||||
|
||||
Known Icons:
|
||||
-------------
|
||||
EOS
|
||||
color_wrapper('reset');
|
||||
while (my $line = <$icon_filehandle>) {
|
||||
chomp $line;
|
||||
say $line;
|
||||
$desktop_relation{$line} = 1;
|
||||
}
|
||||
close $icon_filehandle;
|
||||
|
||||
color_wrapper('red');
|
||||
say << 'EOS';
|
||||
|
||||
Missing icons:
|
||||
-------------
|
||||
EOS
|
||||
color_wrapper('reset');
|
||||
for my $key (keys %desktop_relation) {
|
||||
unless ($desktop_relation{$key}) {
|
||||
say $key;
|
||||
}
|
||||
}
|
||||
color_wrapper('red');
|
||||
say << 'EOS';
|
||||
|
||||
Not missing in your system icons:
|
||||
-------------
|
||||
EOS
|
||||
color_wrapper('reset');
|
||||
for my $key (keys %desktop_relation) {
|
||||
if ($desktop_relation{$key}) {
|
||||
say $key;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
) <(desktopsearch) <(iconsearch $icon_pack | sort | uniq)
|
||||
}
|
34
missing.sh
34
missing.sh
@ -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=//
|
||||
|
||||
fi
|
||||
done
|
||||
}
|
||||
script_path=$(dirname $0)
|
||||
script_name=$(basename $0)
|
||||
icon_pack=$1
|
||||
|
||||
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
|
||||
. "$script_path/functions.sh"
|
||||
|
||||
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
|
||||
# diff --suppress-common-lines /tmp/.missing-icon-reporter-desktopsearch.tmp /tmp/.missing-icon-reporter-iconsearch.tmp
|
||||
compare_desktop_and_icons $icon_pack;
|
||||
|
Loading…
Reference in New Issue
Block a user