Hey everyone, I have made a little script to convert the icons to a
specific size.
It also makes a backup of your current xpm files.
I am no  Bash programmer, but it works.... so I would suggest someone
who is knowledgeable about it look at my file and see if there is some
better programming that can be done to make this nicer, and if any of
the devs are around (after the holidays of course) I'd like to know if
this can be adapted to be used in the menu updating script.
You can tweak this to make different sizes...
This is something that requires SUDO.
Please make sure you are comfortable running potentially dangerous
commands before testing this out.  I have tested it on my computer, and
it works for me.  I'll attach the file, and put it into the e-mail so it
is available to look at before you download it or run it.  If anything
about it needs to be explained I'd be glad to explain what I did, though
if you are good a shell scripting, I am sure you can think of a better
way of doing this.

the things you can edit are
size=24x24  make this whatever size you like... I find 24x24 is good for
the menu...

I have 2 backup directories....  if you try it once backup is created. 
if backup exists extraBackup is created.
If you keep trying it you will get an error that extraBackup already exists.
backup=/usr/share/pixmaps/backup/
extraBackup=/usr/share/pixmaps/extraBackup/

You will not be prompted for anything except your password at the beginning.
Here it is:


#!/bin/bash
shopt -s nullglob
iconDir=/usr/share/pixmaps/
backup=/usr/share/pixmaps/backup/
extraBackup=/usr/share/pixmaps/extraBackup/
cd "$iconDir"
putfiles=(*.xpm)
size=24x24
echo "This will require a password to backup and convert your icons"
if [ ! -d "$backup" ]; then
echo "Making a backup of $iconDir"
sudo mkdir ${backup}
for file in "${putfiles[@]}"; do
   sudo cp ${file} ${backup}
   echo "$file has been saved to $backup"
done
fi
if [ -d "$backup" ]; then
echo "You have already backed up your files once...  I'll make another
directory called $extraBackup"
sudo mkdir ${extraBackup}
for file in "${putfiles[@]}"; do
   sudo cp ${file} ${extraBackup}
   echo "$file has been saved to $extraBackup"
done
fi

echo "This will convert the xpm files to $size"
for file in "${putfiles[@]}"; do
  echo "Processing $file"
  sudo convert ${file} -scale $size ${iconDir}${file}
  echo "Saved to $iconDir $file"
done

echo "Done!"

-- 
Regards

Attachment: iconFixer.sh
Description: application/shellscript

-- 
Lubuntu-users mailing list
Lubuntu-users@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/lubuntu-users

Reply via email to