You are not logged in.
Good, good...
More and more, I'm finding that setting out exactly what I want a utility to do, under what circumstances, is a good half of the work of actually writing it. Get the algorithm down first - in whatever pseudo-code makes sense to you.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
PS the BL BLOB utility was developed by Damo to deal with this kind of situation. It does a pretty good job now, but turned out to be quite complicated! (2300 line script + config directories...) If you've got a BL install to hand you might like to give it a try.
And maybe slightly simpler to grasp
https://forums.bunsenlabs.org/viewtopic.php?id=5075
Offline
johnraff wrote:PS the BL BLOB utility was developed by Damo to deal with this kind of situation. It does a pretty good job now, but turned out to be quite complicated! (2300 line script + config directories...) If you've got a BL install to hand you might like to give it a try.
And maybe slightly simpler to grasp
https://forums.bunsenlabs.org/viewtopic.php?id=5075
More info! Thank you:)
Online
Finally got a chance to take a twentieth look and . .wait . what?
@johnraff's script of course provided the answer if only I would look properly. Amazing.
So, I now have a working toggle script that will:
On first toggle, change the current theme to the chosen "light-theme".
On second toggle, return to whatever theme you were using before.
The current way I have this written is to initiate a theme script located in:
~/.config/themes/NAME - Where $NAME is the EXACT name of the gtk theme being used. (Adwaita, Nord, etc.)
Inside the ~/.config/theme/named-scripts are the lines to control different aspects of whatever theme the name is associated with.
Below are some examples of a few of the settings you can change "on the fly". Basically, you are just assigning functions to your chosen theme.
This script is for changing to the "Anolis" theme, but could just as easily be Adwaita or Nord.
#!/bin/bash
#### A theme changer to set the theme to your own custom configuration.
### Simply change the named entries below with your own selections.
## Change any of the themes however you like to create custom entries.
# You can also add anything that can be refreshed, wallpaper, conky, etc . . .
# Change gtktheme
xfconf-query -c xsettings -p /Net/ThemeName -s "Anolis"
## Change openbox theme
#sed -i "s/$(grep "<theme>" ~/.config/openbox/rc.xml -A 5 | grep "<name>"| awk -F"[><]" '{print $3}')/"Anolisbox"/g" ~/.config/openbox/rc.xml
xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "Anolisbox" ~/.config/openbox/rc.xml
openbox --reconfigure
## Change Geany theme
sed -i "s/color_scheme=.*/color_scheme=Anolis.conf/g" ~/.config/geany/geany.conf
# Change jgmenu theme
#jgmenu_run gtktheme
jgmenu_run init --apply-obtheme
## Change xfce4-terminal theme
xfce4-term-colors anolis
## Comment the line below for the chosen light theme in the light/dark toggle. Currently Glacier.
rm ~/.cache/temp_theme
The theme script are pretty basic, but serves to change the gtk theme, openbox theme, geany theme, xfce4 theme, and jgmenu theme on the fly. You can also add so much more!
Icon changes, wallpaper, fonts, font sizes, sounds, icons, etc. This means maybe having a theme specifically for different members of the house. Maybe someone who likes large print? or a cool colored theme setup for the kids.
The potential here is amazing for creating your own custom setup for a variety of uses.
Now for the script itself, It is just neat so far.
Here is the updated script:
#!/bin/bash
#
temp_file=~/.cache/temp_theme
if [[ -e $temp_file ]]
then
"$HOME/.config/themes/"$(<$temp_file)""
rm "$temp_file"
else
xfconf-query -c xsettings -p /Net/ThemeName > "$temp_file" &&
"$HOME/.config/themes/Glacier"
fi
In the script above, I am calling Glacier as the light theme.
If you call your theme scripts through another method, like a yad dialog or terminal, you will want to add:
rm ~/.cache/temp_theme
to each script EXCEPT for the chosen light theme, and comment out the rm "$temp_file" line in the script.
In other words, Add this line to all your scripts, and then make sure to comment out whatever theme will be used for your "named" theme in the script above:
## Comment the line below for the chosen light theme in the light/dark toggle.
rm ~/.cache/temp_theme
See the example theme above.
Now for some caveats I guess.
This works fine and well for when using xfce4-xsettings, but what about lx-appearance? or some other program? No idea, but would love to know if it could be done. Can you initiate a gtk theme change through the terminal? If so, then maybe?
This could wind up being a 'one-off' based on my particular needs, but I'm hoping that someone will find it useful.
For Bunsenlabs, The code would need to be changed a bit to get a full theme change, and I've no idea how, or even if you would want to.
Bunsenlabs is already using the 'blob' themes manager that does all sorts of stuff without all the scripting work and generally does a good job. So, it may not matter in the slightest unless you are just looking for something to do. I would use a spare partition myself for such messing around:)
Please know that I want to put as much info as I can think of here, so sorry for the long post. There's a lot here to take in as a bunch of options just opened up.
Thank you @johnraff and @Dobbie03 and @brontosaurusrex for helping me get this made:) We'll see if it will hold up to weird conditions, but so far so good.
Online
Quoting here is wrong I think:
"$HOME/.config/themes/"$(<$temp_file)""
Probably should be
"$HOME/.config/themes/$(<"$temp_file")"
Once you've started a double-quote, you don't need any more. But, inside the ( ) brackets is a subshell with its own world, so better to quote $temp_file.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
Quoting here is wrong I think:
sleekmason wrote:"$HOME/.config/themes/"$(<$temp_file)""
Probably should be
"$HOME/.config/themes/$(<"$temp_file")"
Once you've started a double-quote, you don't need any more. But, inside the ( ) brackets is a subshell with its own world, so better to quote $temp_file.
I like how you put that. Clicked immediately. Thank you:)
Last edited by sleekmason (2022-08-07 13:38:10)
Online