Last active
November 23, 2019 17:44
-
-
Save Ark74/66e726123a4400123f283bbf99df30bd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Basic bash desktop file crawler | |
# 2019 - Luis Guzman <[email protected]> | |
##Check superuser | |
#if ! [ $(id -u) = 0 ]; then | |
# echo "You need to be root or have sudo privileges!" | |
# exit 0 | |
#fi | |
#Check for necessary packages | |
sudo apt -yq4 install apt-file dpkg | |
sudo apt-file update | |
#Keep apt-file lists for debug porpuses | |
apt-file search "/usr/share/applications/" | grep .desktop > apt-file_desktop.txt | |
cat apt-file_desktop.txt | awk -F':' '{print $1}' | awk '!NF || !seen[$0]++' > apt-file_packages.txt | |
#Create storage for deb files | |
mkdir packages | |
cd packages | |
#Download marked deb packages | |
#check the true options to only use them instead of all unnecesary path | |
apt -o Dir::Cache::Archives=~/packages download $(cat ~/apt-file_packages.txt| xargs) | |
#Extract .desktop file | |
for f in `ls -1 *.deb | sed 's/\(.*\)\..*/\1/'` | |
do | |
dpkg-deb --fsys-tarfile $f.deb | tar -xvf - --wildcards ./usr/share/applications/\*.desktop | |
done | |
### Cleaning of .desktop files ### | |
#GUI specific "OnlyShowIn" | |
rm -f $(grep -r OnlyShowIn ./usr | awk -F':' '{print $1}' | awk '!NF || !seen[$0]++') | |
#No icon described on desktop file | |
rm -r $(grep -Lr Icon ./usr | awk -F':' '{print $1}' | awk '!NF || !seen[$0]++') | |
#Remove empty folders | |
find . -type d -empty -delete | |
#Package .desktop files | |
tar -czvf desktop_archive.tar.gz usr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment