I have released an updated version of my xfce-appentry-optimize script, and renamed it to appentry-optimize as it can now be used in Gnome, Xfce, KDE 3.x, KDE 4 and any freedesktop.org compliant desktop.
The purpose of this program is to dramatically reduce the size of .desktop files on the system by removing unused locales. It is safe to use but does require root to modify the files. Download here if you want to skip all the boring stuff.
How to use
In order to use appentry-optimize you need to specify a locale you wish to keep. By default, non localized entries are also kept. In order to modify the locale you wish to keep, you must edit the script and find the section as follows:
# User definable variables
# Do not forget to update the locale section.# locale defines the locale you wish to KEEP in the optimization process. All other locales
# will be removed. If no locale is specified (or invalid), then it will remove ALL locales apart from the
# one with no locale specification. (example: en_GB, fr, ca)
locale = “en_GB”
You must then replace en_GB with the locale you want to keep. A list of valid locales is checked by the program to help ensure a valid locale is provided.
Program Options
The program now supports three command line switches. These are:
–enable-verbosity, -v — Enable verbose mode for more output.
–enable-backup, -b — Enable backup.
–help, -h — Display help.
Backup option
Enabling the backup will save a copy of your desktop files in a compressed tar ball in /usr/share/applications/backup. It will take the filename of backup-[timestamp].tar.gz, where timestamp is a time and date. By default, backup is disabled and must be enabled using the -b option.
Changes in 0.3
The following changes have been made in 0.3 (from 0.2.2)
- Modified final report (now reports kB instead of bytes) and displays full original bytes.
- Checks to see if backup/ directory already exists before creating it.
- Multiple backups are now possible (rather than backup.tar.gz it will be backup[date-time].tar.gz)
- Added command line arguments. Use -b to enable backup, -h to display help and -v for increased verbosity.
- Verbosity by default is now decreased. Use the new option -v for increased verbosity.
- KDE 3.x and 4 support
- Only attempts to optimize .desktop files now.
- A check is now performed to help ensure a valid locale is given.
Get It
It can be downloaded from http://kahrn.pastebin.com/f662e0502 or http://code.tdlabs.co.uk/appentry-optimize/appentry-optimize-rel-0.3.py.
If you want to be snazzy,
wget http://code.tdlabs.co.uk/appentry-optimize/appentry-optimize-rel-0.3.py && sudo python appentry-optimize-rel-0.3.py
Finally, for developers — The specification
The specification for .desktop files can be found here. appentry-optmize follows the specification by not removing required fields — It only removes the locales you do not wish to keep. Locales are not required by the specification, thus this program will not break the specification in any way.