0

In the continuation of Using sed to replace the hexadecimal code for URL and to insert new SVG codes after SVG tag in all SVG files, I would like to find an icons theme somewhere to cd and then to replace and add/insert in all SVG files in multiple specific folders.

Taking the codes from the file replace.sh from the link above. I am not sure if my bash/shell codes are bad and inelegant in your eyes.

Here is my complete code:

  1. Firstly begins the function go_dir_to_breeze. You can see the conditions in the end of code, in the which it will locate the existent icons theme somewhere. If it is found, you will enter in the function go_dir_to_breeze and begin the item (2).
  2. After found successfully, you are entering in the function change_colour(), which will begin the sed to replace and string, calling foo.pl, but instead, it will hear to the variable of the chosen colour/gradient in the conditions before beginning to call change_colour(). If the colour/gradient is found, it will begin to call foo.pl to replace and insert.
  3. The terminal will change the directory with cd, which will call the function change_colour().

For example:

echo "Which type of colour do you prefer? Write the nummber"
echo "1) solid 2) gradient"
read type

if [$type = "1"]; then
    echo "Write one of these colours to choose your favourite:"
    echo "black gold green\n grey orange purple\n red yellow"
    read color
else
    echo "Write one of these letters to choose your favourite gradient:"
    echo "a) telinkrin b) arrogrin c) minoan"
    read color
fi

go_dir_to_breeze()
{

    change_colour()
    {
        for f in *svg; do
            case "$color" in
            a)
                perl gradient1.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            b)
                perl gradient2.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            c)
                perl gradient3.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            black)
                perl black.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            gold)
                perl gold.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            green)
                perl green.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            grey)
                perl grey.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            orange)
                perl orangle.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            purple)
                perl purple.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
            red)
                perl red.pl "$f" > tmpFile && mv tmpFile "$f"
                ;;
        esac
        done
    }

    cd apps='apps/16'
    change_colour
    cd ..

    cd places='places/16'
    change_colour
    cd ..

    cd mimetypes='mimetypes/16'
    change_colour

}

if [ find /home/$USER/.icons/breeze ]; then
    go_dir_to_breeze
elif [ find /home/$USER/local/share/icons/breeze ]; then
    go_dir_to_breeze
# Observe that to change the colour of icons, it is required to run as root
elif [ find /usr/share/icons/breeze ]; then
    go_dir_to_breeze
else
    echo "Icons theme Breeze does not exist!"
fi

Are the conditions of finding the directories of icons theme good and bad? And is cding multiple specific folders to call the function change_colour good or bad?

So maybe the user can receive the errors in these cases.

closed as unclear what you're asking by l0b0, RalfFriedl, Isaac, Stephen Harris, Mr Shunz Jan 7 at 11:21

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.