When I search for a way to change the gtk theme in Linux, I find that there is a different way to do it for every desktop environment. The only one I found that worked on all desktop environments was by changing a configuration file manually (https://unix.stackexchange.com/a/323065), but the problem with this solution is that it is only applied after a reboot. Is there any way to change the GTK theme on any desktop environment through the command line that applies without a reboot (even if the theme is only applied untill the user logs out)?
EDIT: A way to do this in C or Python is an accepted answer as well