deviantfero / wpgtk

:flower_playing_cards: a colorscheme, wallpaper and template manager for *nix
http://deviantfero.github.io/wpgtk/
GNU General Public License v2.0
2.06k stars 49 forks source link

Run command after colorize executes the command indefinitely #175

Closed vide0hanz closed 4 years ago

vide0hanz commented 4 years ago

Not sure if this is a bug or working as intended, so my apologies if this does not belong here.

While playing around with this feature I noticed that whatever command you set to run after applying a theme will continue to run forever. Is it possible for the command to only be run a single time?

For example: I'm using bspwm and I input bspc wm -r as the command in order to update the colors bspwm uses in real time. It works, but it continues to "work" making my desktop unusable due to it constantly reloading bspwm seemingly every 0.5 seconds.

Forgive me if there is an obvious solution to this elsewhere, or if this is by design, but figured I'd post this here because I can't see any reason why the command should be running indefinitely.

deviantfero commented 4 years ago

Ok, so after digging in a little, I found the issue, it has nothing to do with wpgtk, but with the fact that you're calling bspc wm -r to reload your bspwm, and in turn I'm almost sure your bspwmrc has this line in it:

bash "$HOME/.config/wpg/wp_init.sh" &

which sets off an infinite loop of reloading bspwm, luckily you can reload colors without restarting bspwm using bspc, you need to install the bspwm template, like this:

wpg-install.sh -b

this will install a script for bspwm colors in your bspwm config folder $HOME/.config/bspwm/bspwm_colors.sh and add a line at the end of your bspwmrc that calls this script after it's been processed, it also installs a template that replaces colors in that script after each wpgtk color scheme has been set.

the contents of that template are:

#!/bin/bash

bspc config focused_border_color "{active}"
bspc config normal_border_color  "{inactive}"

you can then replace your script setting with /home/user/.config/bspwm/bspwm_colors.sh

please let me know if you have trouble following me on this, :sweat_smile: I've tried to be as through as possible, I could also disable the script execution when the reload flag is used, like in wpg_init.sh, but this only happens with bspwm because it cannot differentiate a start up script from anything in it's config, so it executes everything everytime.

vide0hanz commented 4 years ago

This makes sense! Thank you :smile:

Just so I'm clear on this, I would have to remove the line ~/.config/wpg/wpg_init.sh & from my bspwmrc and replace it with the bspwm_colors.sh script you have created? I will have to play around with this some more later tonight.

Also, a note about the templates... I get the concept behind them but if you're using pywal as it's backend and modifying the colorschemes with wpgtk, is it really necessary to use them? I love the feature and I can absolutely see the benefits of controlling this with one unified program, but what I have been doing is just modifying the colors within wpg's gui which of course updates the pywal colorschemes and any application using those variables.

deviantfero commented 4 years ago

no, don't remove the wpg_init.sh that reloads your terminal colors and your wallpaper on startup!, both should be there, a template is just a user defined pywal template with a few more perks, it is meant to be linked to a configuration file that you want to affect, it gives you a few more colors too, such as {active} and {inactive}, you can also define your own keywords to replace in templates, you can read more about it here:

https://github.com/deviantfero/wpgtk/wiki/Templates

vide0hanz commented 4 years ago

I get the concept but I've had issues making it work in the past, but this is probably just down to me not configuring something correctly on my system.

That said, I followed your instructions and initially left wpg_init.sh in the bspwmrc but it was not updating the colorscheme until I ran bspc wm -r - but if I ran that as a command in wpg, it would set off an infinite loop as you described... so here was my workaround:

I created a basic script named colorize.sh containing the following:

timeout 0.1s xsettingsd -c $HOME/.config/xsettingsd/xsettingsd.conf & wal -R & ~/.config/wpg/templates/bspwm_colors &

Then I input the bspc wm -r command to run in wpgtk

I added the new script to my bspwm autostart section and voila! This works as expected, gtk themes (including the wpg gui), terminal colors, and bspwm colors all reload instantly. This is a pretty hacky workaround, but it does what I need... I'm just not sure how to get it working as you have intended it. AFAIK, bspwm needs to be reloaded in place in order for the colors to update.

vide0hanz commented 4 years ago

I've tried everything I can think of to get bspwm to reload the colors without restarting and I don't think this is possible without some sort of interrupt command... however, your template works exactly as designed. Closing issue since this isn't an issue with wpgtk. Thanks again for helping to clarify a couple of things!