I know its a pain to fix all the packages that's why this is a workaround without effecting the installed files
if you want to "grep out info " having it organized in arrarys first allows you find the info with
less code filters most of the problem with writing scripts is because "we start with un formatted files "
make a template of all the desktops and lets you view them in /tmp/desktops
so none of your original desktops get overwritten
builds an array for speeding up any scripts that search info from the desktop
now all your desktops will have a format and an organized template
the first line is [Desktop Entry],Name,Icon,Type,Categories,Exec,Comment,MimeType
and thats what you will expect to see when you search the desktops for info they will all follow this format
[Desktop Entry]
Name=Image Viewer
Icon=gpicview
Type=Application
Categories=Graphics;Utility;Core;GTK;Viewer;RasterGraphics;2DGraphics;Photography;
Exec=gpicview %f
Comment=View your images easily
MimeType=image/bmp;image/gif;image/jpeg;image/jpg;image/png;image/tiff;image/x-bmp;image/x-pcx;image/x-tga;image/x-portable-pixmap;image/x-portable-bitmap;image/x-targa;image/x-portable-greymap;application/pcx;image/svg xml;image/svg-xml;
Code: Select all
#!/bin/bash
# make a template of the desktops regenerate all desktops to the new simple template
# removes poorly formatted desktops and creates a standard which allows later for easy reading of strings
# into an array to speed up scripts since the newly generated desktops maintain a standard format
# less commands are needed to filter data for output this is where all the time is wasted
# having to parse poorly formatted files from the start if you have organized files
# everything is fast and easy to parse the code
:>/tmp/arraytest.txt
mkdir -p /tmp/desktops
for DESKTOP_FILE in /usr/share/applications/* ; do
while read LINE ; do
case $LINE in
Name=*) NAME="${LINE[@]}"'|' ;;
Icon=*) ICON="${LINE[@]}"'|' ;;
#Terminal=*)
Type=*) TYPE="${LINE[@]}"'|' ;;
Categories=*) CATS="${LINE[@]}"'|' ;;
Exec=*) EXEC="${LINE[@]}"'|' ;;
Comment=*) COMM="${LINE[@]}"'|' ;;
MimeType=*) MIMETYPE="${LINE[@]}"'|' ;;
esac
done < $DESKTOP_FILE
echo "."
# fixes spaces in the string names by replacing them with a "+" making a correctly formatted array
echo '[Desktop+Entry]|'$NAME$ICON$TYPE$CATS$EXEC$COMM$MIMETYPE | tr ' ' '+' >>/tmp/arraytest.txt
#uncomment if you want to generate all new desktops in /temp/desktops
echo '[Desktop+Entry]|'$NAME$ICON$TYPE$CATS$EXEC$COMM$MIMETYPE | tr ' ' '+' | tr '| ' ' ' | tr ' ' '\n' | tr '+' ' '>/tmp/desktops/`basename $DESKTOP_FILE`
done
if you want to fix KDE desktops too here it is
Code: Select all
#!/bin/bash
# kde version
# make a template of the desktops regenerate all desktops to the new simple template
# removes poorly formatted desktops and creates a standard which allows later for easy reading of strings
# into an array to speed up scripts since the newly generated desktops maintain a standard format
# less commands are needed to filter data for output this is where all the time is wasted
# having to parse poorly formatted files from the start if you have organized files
# everything is fast and easy to parse the code
:>/tmp/arraytest.txt
mkdir -p /tmp/desktops/kde-folder
for DESKTOP_FILE in /usr/share/applications/kde/* ; do
while read LINE ; do
case $LINE in
Name=*) NAME="${LINE[@]}"'|' ;;
Icon=*) ICON="${LINE[@]}"'|' ;;
#Terminal=*)
Type=*) TYPE="${LINE[@]}"'|' ;;
Categories=*) CATS="${LINE[@]}"'|' ;;
Exec=*) EXEC="${LINE[@]}"'|' ;;
Comment=*) COMM="${LINE[@]}"'|' ;;
MimeType=*) MIMETYPE="${LINE[@]}"'|' ;;
esac
done < $DESKTOP_FILE
echo "."
# fixes spaces in the string names by replacing them with a "+" making a correctly formatted array
echo '[Desktop+Entry]|'$NAME$ICON$TYPE$CATS$EXEC$COMM$MIMETYPE | tr ' ' '+' >>/tmp/arraytest.txt
#uncomment if you want to generate all new desktops in /temp/desktops
echo '[Desktop+Entry]|'$NAME$ICON$TYPE$CATS$EXEC$COMM$MIMETYPE | tr ' ' '+' | tr '| ' ' ' | tr ' ' '\n' | tr '+' ' '>/tmp/desktops/kde-folder/`basename $DESKTOP_FILE`
done