gusbemacbe / suru-plus-colourise

Colourise the small icons with any colour and gradient you prefer!
Other
4 stars 0 forks source link

I invite you to contribute for improving #1

Closed gusbemacbe closed 5 years ago

gusbemacbe commented 5 years ago

Hello @SmartFinn!

I am inviting you to contribute and to improve this little repository.

I am not sure if these codes are bad and inelegant for you. If so, you can improve (only when you have time) if you want.

Little problem is that, these files do not preserve the symlinks. I found the solutions, they preserved the symlinks, but they makde them unsuable.

Based on:

I also would like to replace Perl files for Bash files, because Bash offers --in-place --follow-symlinks, but I am not sure I can something similar in Bash to that in Perl.

I am not sure it works for any terminal and if it is bash-agnostic.

Please do not forget of putting your credit on AUTHORS and CREDIT.

actionless commented 5 years ago

nice, thanks a lot!

gusbemacbe commented 5 years ago

@actionless

I have just updated, adding new translations.

SmartFinn commented 5 years ago

@gusbemacbe

Replace

-e 's/currentColor/url(#arrongin)/g' \
-e "s/dd9b44/$SURUPLUS_GRADIENT1/g" \
-e "s/ad6c16/$SURUPLUS_GRADIENT2/g" '{}' \;

for

-e 's/currentColor/url(#oomox)/g' \
-e "s/efefe7/$SURUPLUS_GRADIENT1/g" \
-e "s/8f8f8b/$SURUPLUS_GRADIENT2/g" '{}' \;

As I write before there is not much point to adding the separate gradient for oomox. I didn't notice that you added it so I just used arrongin as the template. I don't think that we have to change it now.

gusbemacbe commented 5 years ago

@SmartFinn

Yes, as @actionless thought it is unncessary, we left it like.

gusbemacbe commented 5 years ago

Hello @actionless and @SmartFinn !

I have upgraded the repository. I changed the files. I removed the files.

See the new Bash files and say if they are good or not. If they are not good, you are free to modify and improve.

actionless commented 5 years ago

Showing 19,519 changed files with 272 additions and 301,982 deletions. The diff you're trying to view is too large. We only load the first 3000 changed files.

:skull: :gun:

gusbemacbe commented 5 years ago

Showing 19,519 changed files with 272 additions and 301,982 deletions.

Maybe because of the folders that I have removed from this repository as 16, test-for-oomox and test-for-oomox-2. All folders had together 15540 icons.

If it is not this, are you referring to the shell files that were destroying and removing the icons theme?

actionless commented 5 years ago

ok, so i've reviewed the files manually

for example:

if grep --quiet 'url(#arrongin)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#arrongin)/url(#fitdance)/g'
elif grep --quiet 'url(#aurora)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#aurora)/url(#fitdance)/g'
elif grep --quiet 'url(#oomox)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#oomox)/url(#fitdance)/g'
elif grep --quiet 'url(#rainblue)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#rainblue)/url(#fitdance)/g'
elif grep --quiet 'url(#sunrise)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#sunrise)/url(#fitdance)/g'
elif grep --quiet 'url(#telinkrin)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#telinkrin)/url(#fitdance)/g'
elif grep --quiet 'url(#60spsycho)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#60spsycho)/url(#fitdance)/g'
elif grep --quiet 'url(#90ssummer)' *.svg; then
  sed --in-place --follow-symlinks *.svg -e 's/url(#90ssummer)/url(#fitdance)/g'
else
  sed --in-place --follow-symlinks *.svg -e 's/currentColor/url(#fitdance)/g'
fi

it could be refactored like:

NEW_COLOR="url(#fitdance)"

ALL_COLORS=(
  "url(#90ssummer)"
<.....>
  "url(#sunrise)"
  "currentColor"
)

for color in "${ALL_COLORS[@]}" ; do
  if grep --quiet "$color" *.svg; then
    sed --in-place --follow-symlinks *.svg -e 's/'"$color"'/'"$NEW_COLOR"'/g'
    break
  fi
done
gusbemacbe commented 5 years ago

Nice codes simplification, @actionless ! I have just updated, I will test at my own risk.

gusbemacbe commented 5 years ago

A small fail. The terminal said "grep: *.svg: No such file or directory".

actionless commented 5 years ago

but it's the same what your original code do

try running each command manually in terminal to understand how they should be modified in script to work correctly

grep --quiet "$color" *.svg

means

grep (without std output) color in all .svg files in the current directory

you probably need to prepend it with find like here: https://github.com/gusbemacbe/suru-plus-colourise/issues/1#issuecomment-465455962

gusbemacbe commented 5 years ago

@actionless

I understood what happened, because of https://github.com/gusbemacbe/suru-plus-colourise/blob/ac8b46624be5820c00b88481793db7515ede1d80/change_color.sh#L64-L78.

The @SmartFinn codes you suggested were for creating a new icons theme, but I will try to use find without generating a new icons theme.

gusbemacbe commented 5 years ago

if grep --quiet "$color" *.svg; for if find -type f -name '*.svg' -exec grep --quiet "$color" *.svg;, is it correct? With or without brackets?

gusbemacbe commented 5 years ago

Or I must remove for file_path in "$theme_dir/$context_dir/"*.svg; do from those lines I showed you.

actionless commented 5 years ago

just try running find -type f -name '*.svg' -exec grep --quiet "$color" *.svg; in the terminal too see if it works for your case (and do color=something before of course)

gusbemacbe commented 5 years ago

I also did it and received a warning "lack of argument for -exec".

actionless commented 5 years ago

yup, replace *.svg at the end to '{}' \;

actionless commented 5 years ago

and also do grep -m 1 instead of just grep (performance tuning :D)

gusbemacbe commented 5 years ago

And still sed: unable to get informations from *.svg: No such file or directory It seems that Suru++ is in the /usr/share/icons/ and the script is denied to access to that directory.

gusbemacbe commented 5 years ago

Ah, I also tried with sudo and I received the same warning.

actionless commented 5 years ago

have you modified sed command the same as you modifed grep?

actionless commented 5 years ago

also you need to specify target dir to find, like find ./dirname -type f -name '*.svg'

gusbemacbe commented 5 years ago

No, here:

NEW_COLOR="url(#fitdance)"

ALL_COLORS=(
  "url(#arrongin)"
  "url(#aurora)"
  "url(#oomox)"
  "url(#rainblue)"
  "url(#sunrise)"
  "url(#telinkrin)"
  "url(#60spsycho)"
  "url(#90ssummer)"
  "currentColor"
)

for color in "${ALL_COLORS[@]}" ; do
  if find -type f -name '*.svg' -exec grep -m 1 "$color" '{}' \; then
    sed --in-place --follow-symlinks *.svg -e 's/'"$color"'/'"$NEW_COLOR"'/g'
    break
  fi
done

find ./dirname

The file change_colour.sh has already that, may I put this?

actionless commented 5 years ago

ah, wait, you don't need find at all, i see those script are not independent but they should be called by your change-color script

actionless commented 5 years ago

so just add cd $1 command before for iteration and it gonna be fine

gusbemacbe commented 5 years ago

so just add cd $1 command before for iteration and it gonna be fine

in the file change_colour.sh or fitdance.sh?

actionless commented 5 years ago

hm, that also wouldn't work

was this script even working before?

i think you can just rewrite it all with find as single script (https://github.com/gusbemacbe/suru-plus-colourise/issues/1#issuecomment-466614797) instead of having 10 scripts

just instead of having NEW_COLOR pre-defined read it from user

gusbemacbe commented 5 years ago

@actionless

The fitdance.sh with the original codes worked when I used cd to /opt/Suru++/apps/16, running as sudo ~/suru-plus-colourise/fitdance.sh. I will test withchange_colour.sh`.

Ah, the problem is change_colour.sh, I will add the /opt/Suru++/apps/16 to change_colour.sh and test.

gusbemacbe commented 5 years ago

The concluding, the problem is change_colour.sh. All other 9 files are OK.

gusbemacbe commented 5 years ago

Better to let @SmartFinn know what's wrong with the file change_colour.sh.

SmartFinn commented 5 years ago

@gusbemacbe

The concluding, the problem is change_colour.sh. All other 9 files are OK.

Hahaha, but that's not so. change_colour.sh is OK. The 9 files do something weird.

actionless commented 5 years ago

@SmartFinn

i think you can just rewrite it all with find as single script (#1 (comment)) instead of having 10 scripts

just instead of having NEW_COLOR pre-defined read it from user

SmartFinn commented 5 years ago

@actionless yep, I have an idea.

SmartFinn commented 5 years ago

Now change_color.sh cannot change colors. Maybe it should be renamed to switch_gradients.sh.

gusbemacbe commented 5 years ago

@SmartFinn

I was unaware of your last message, but is this current commit and README OK?