2022-02-06 03:15:37 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-02-06 20:48:29 +01:00
|
|
|
# This file is part of IconToaster
|
2022-02-06 03:15:37 +01:00
|
|
|
# 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
|
2022-02-07 16:23:44 +01:00
|
|
|
echo "IconToaster requires an icon pack as an argument." 1>&2
|
2022-02-06 03:15:37 +01:00
|
|
|
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
|
2022-02-07 16:23:44 +01:00
|
|
|
echo "IconToaster requires an icon pack as an argument." 1>&2
|
2022-02-06 03:15:37 +01:00
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
perl <(cat <<'EOF'
|
|
|
|
use v5.30.0;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2022-02-06 04:40:14 +01:00
|
|
|
use Term::ANSIColor;
|
|
|
|
|
|
|
|
$SIG{INT} = sub {
|
|
|
|
color_wrapper('reset');
|
|
|
|
};
|
|
|
|
|
|
|
|
sub color_wrapper {
|
|
|
|
print color(shift) if -t STDOUT || $ENV{TOASTER_COLOR};
|
|
|
|
}
|
|
|
|
|
|
|
|
color_wrapper('yellow');
|
2022-02-06 20:48:29 +01:00
|
|
|
say 'This is IconToaster';
|
2022-02-06 04:40:14 +01:00
|
|
|
color_wrapper('reset');
|
|
|
|
|
2022-02-06 03:15:37 +01:00
|
|
|
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;
|
2022-02-06 04:40:14 +01:00
|
|
|
|
2022-02-06 20:48:29 +01:00
|
|
|
color_wrapper('blue');
|
2022-02-06 04:40:14 +01:00
|
|
|
say << 'EOS';
|
|
|
|
|
2022-02-07 16:16:19 +01:00
|
|
|
In both your icon pack and system:
|
2022-02-06 03:41:21 +01:00
|
|
|
-------------
|
2022-02-06 04:40:14 +01:00
|
|
|
EOS
|
|
|
|
color_wrapper('reset');
|
2022-02-06 03:15:37 +01:00
|
|
|
while (my $line = <$icon_filehandle>) {
|
|
|
|
chomp $line;
|
2022-02-06 03:41:21 +01:00
|
|
|
say $line;
|
2022-02-06 03:15:37 +01:00
|
|
|
$desktop_relation{$line} = 1;
|
|
|
|
}
|
|
|
|
close $icon_filehandle;
|
|
|
|
|
2022-02-06 04:40:14 +01:00
|
|
|
color_wrapper('red');
|
|
|
|
say << 'EOS';
|
|
|
|
|
2022-02-07 16:16:19 +01:00
|
|
|
Missing (In your system and not in your icon pack):
|
2022-02-06 03:41:21 +01:00
|
|
|
-------------
|
2022-02-06 04:40:14 +01:00
|
|
|
EOS
|
|
|
|
color_wrapper('reset');
|
2022-02-06 03:15:37 +01:00
|
|
|
for my $key (keys %desktop_relation) {
|
|
|
|
unless ($desktop_relation{$key}) {
|
2022-02-06 03:41:21 +01:00
|
|
|
say $key;
|
2022-02-06 03:15:37 +01:00
|
|
|
}
|
|
|
|
}
|
2022-02-06 20:48:29 +01:00
|
|
|
color_wrapper('green');
|
2022-02-06 04:40:14 +01:00
|
|
|
say << 'EOS';
|
|
|
|
|
2022-02-07 16:16:19 +01:00
|
|
|
Unused icons from your icon pack:
|
2022-02-06 04:40:14 +01:00
|
|
|
-------------
|
|
|
|
EOS
|
|
|
|
color_wrapper('reset');
|
|
|
|
for my $key (keys %desktop_relation) {
|
|
|
|
if ($desktop_relation{$key}) {
|
|
|
|
say $key;
|
|
|
|
}
|
|
|
|
}
|
2022-02-06 03:15:37 +01:00
|
|
|
EOF
|
2022-02-06 04:40:14 +01:00
|
|
|
) <(desktopsearch) <(iconsearch $icon_pack | sort | uniq)
|
2022-02-06 03:15:37 +01:00
|
|
|
}
|