gh0stzk / dotfiles

BSPWM environment with 18 themes. With a theme selector to change on the fly.
GNU General Public License v3.0
2.46k stars 187 forks source link

Colorscript bug #256

Closed 0xN1nja closed 1 month ago

0xN1nja commented 1 month ago

So, this issue has been happening since I added your latest colorscript to my config. The colorscript is not executing zwaves. It is executable when run manually:

image

Even colorscript can execute it:

image

But the colorscript -r command never executes it. I've tried running colorscript -r over 50 times, but not a single time it executed zwaves. This is very weird, I don't know why it's happening.

zwaves even gets listed in the output of colorscript -l:

image

AzhamProdLive commented 1 month ago

image Can reproduce, error is here

0xN1nja commented 1 month ago

@AzhamProdLive wrong command. -r flag is used to run a random colorscript.

AzhamProdLive commented 1 month ago

@AzhamProdLive wrong command. -r flag is used to run a random colorscript.

Yeah I noticed after I sent it, you just happen to have bad luck, it works on my machine after 22 try

image

0xN1nja commented 1 month ago

That's weird :/ are you using the latest colorscript?

AzhamProdLive commented 1 month ago

Yes, I do have the latest

0xN1nja commented 1 month ago

I think maybe your colorscript is not able to execute any other ascii art (zwaves in my case). Can you check it once?

AzhamProdLive commented 1 month ago

I get all of them, from those I still have (so only 8), can't reproduce

gh0stzk commented 1 month ago

Hello, is a legit bug as seen here https://gitlab.com/dwt1/shell-color-scripts/-/commit/32e2feefcdd01dcf348b22749ffd9875f8438b25 But the version that the dotfiles use is this https://github.com/charitarthchugh/shell-color-scripts. Before, I used the one from Derek Taylor Distro Tube but it kept getting bloated and I changed to the recent one.

I can't reproduce the bug either since it appears, in my case it took me 9 attempts.

Shot-2024-06-02-124558

2 new themes are coming, and a bluetooth manager in rofi with his respective polybar module.

0xN1nja commented 1 month ago

I finally found the bug. It's on line 26 of colorscript. We are starting the random_index from 1; not 0, which is why the "nth" (last) script is not being executed.

Whenever there were 2 scripts in the colorscripts directory, only 1 was being executed. When there were 3 scripts in the colorscripts directory, only 2 were being executed randomly. And when there were 4 scripts, only 3 were being executed randomly.

Hence, n-1 scripts were being executed. The "nth" script (or the last script) was never being executed.

So, I changed the random_index from:

declare -i random_index=$RANDOM%$length_colorscripts

to:

declare -i random_index=$((RANDOM % length_colorscripts + 1))

It took me a lot of time to figure this out, but now it's working. I don't know how it was working for you all, maybe you were missing something.