You are not logged in.
I have made scripts to change gtk-theme, icon-theme and switch out configs for tint2, xfce4-terminal and more. The only thing I need is a script to change openbox theme then I can change all appearance with a string of scripts from the terminal as an alias, but can't find the commands I need for changing ob theme.
Example from my gtkswitch script
#!/bin/sh
# Displays a list of files in current directory and prompt for which
# file to edit
# Set the prompt for the select command
PS3="Type a number or 'q' to quit: "
# Create a list of files to display
fileList=$(cat $(find ~/.themes -name index.theme) | grep "Name=" | cut -d "=" -f2 | sort -n)
# Show a menu and ask for input. If the user entered a valid choice,
# then invoke the editor on that file
select fileName in $fileList; do
if [ -n "$fileName" ]; then
sed -i "s/.*gtk-theme-name=.*/gtk-theme-name=${fileName}/g" ~/.config/gtk-3.0/settings.ini
sed -i "s/.*gtk-theme-name=.*/gtk-theme-name=${fileName}/g" ~/.gtkrc-2.0
fi
break
done
the other scripts are in the same style so nothing fancy but, yeah, just need the last script to change openbox theme. Here is another example for tint2
#!/bin/sh
# Displays a list of files in current directory and prompt for which
# file to edit
# Set the prompt for the select command
PS3="Type a number or 'q' to quit: "
# Create a list of files to display
fileList=$(find ~/.config/tint2 -name *tint2rc -type f)
# Show a menu and ask for input. If the user entered a valid choice,
# then invoke the editor on that file
select fileName in $fileList; do
if [ -n "$fileName" ]; then
cp ${fileName} ~/.config/tint2/tint2rc
fi
break
done
killall tint2
tint2 &
Last edited by lbdesign (2021-05-14 09:03:50)
Offline
BL has the inbuilt BLOB themes manager to do all of those things. If you want to see how we accomplish what you want, then have a look at /usr/bin/bl-obthemes. The functions for changing the Openbox themes are
function getOBtheme()
function getOBname()
function restoreOBrc()
You should find something useful for your scripts in there
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
Thanks. I'm not a coder (this is as advanced I have ever done) but I'll see what I can find.
Offline
Basically it is using sed to find and replace the theme name in bl-rc.xml, then running
openbox --reconfigure
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
Here is the finished script so far. Still more to do but it works good enough for now.
#!/bin/sh
# switch gtk theme
clear
echo -e "Choose gtk theme \n"
PS3="Type a number or 'q' to quit: "
fileList=$(find ~/.themes -maxdepth 1 -type d | grep -v "ob-*" | cut -d "/" -f5 | sort -n)
select fileName in $fileList; do
if [ -n "$fileName" ]; then
sed -i "s/.*gtk-theme-name=.*/gtk-theme-name=${fileName}/g" ~/.config/gtk-3.0/settings.ini
sed -i "s/.*gtk-theme-name=.*/gtk-theme-name=${fileName}/g" ~/.gtkrc-2.0
fi
break
done
# switch icon theme
clear
echo -e "Choose icon theme \n"
PS3="Type a number or 'q' to quit: "
fileList=$(find ~/.icons -maxdepth 1 -type d | cut -d "/" -f5 | sort -n)
select fileName in $fileList; do
if [ -n "$fileName" ]; then
sed -i "s/.*gtk-icon-theme-name=.*/gtk-icon-theme-name=${fileName}/g" ~/.config/gtk-3.0/settings.ini
sed -i "s/.*gtk-icon-theme-name=.*/gtk-icon-theme-name=${fileName}/g" ~/.gtkrc-2.0
fi
break
done
# switch openbox theme
clear
echo -e "Choose openbox theme \n"
PS3="Type a number or 'q' to quit: "
fileList=$(find ~/.themes -type d -name "openbox-3" | cut -d "/" -f5)
select fileName in $fileList; do
if [ -n "$fileName" ]; then
sed -i "s/$(grep "<theme>" ~/.config/openbox/rc.xml -A 5 | grep "<name>"| awk -F"[><]" '{print $3}')/$fileName/g" ~/.config/openbox/rc.xml
openbox --reconfigure
fi
break
done
# switch xfce4-terminal config
clear
echo -e "Choose xfce4-terminal config \n"
PS3="Type a number or 'q' to quit: "
fileList=$(find ~/.config/xfce4/terminal -name *terminalrc* -type f)
select fileName in $fileList; do
if [ -n "$fileName" ]; then
cp ${fileName} ~/.config/xfce4/terminal/terminalrc
fi
break
done
# switch tint2 config
clear
echo -e "Choose tint2 config \n"
PS3="Type a number or 'q' to quit: "
fileList=$(find ~/.config/tint2 -name *tint2rc -type f)
select fileName in $fileList; do
if [ -n "$fileName" ]; then
cp ${fileName} ~/.config/tint2/tint2rc
fi
break
done
openbox --exit
be aware of the last line if you run it
Last edited by lbdesign (2021-05-14 13:43:48)
Offline
Just a general remark, when dealing with small files like this config stuff, I tend to use the -b switch with cp, just in case.
cp -b src dst
which should do a backup of dst named dst~.
edit: Also maybe interesting, https://forums.bunsenlabs.org/viewtopic.php?id=5075
Last edited by brontosaurusrex (2021-05-15 20:17:40)
Offline
lbdesign, I do it like this:
cp -f "$ob_rc" "$ob_rc"."$me"
# priceless piece of information: https://superuser.com/a/508143
xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "$CURRENT_THEME" "$ob_rc"
xmlstarlet is a more suitable tool for editing XML files.
Offline
Just a general remark, when dealing with small files like this config stuff, I tend to use the -b switch with cp, just in case.
I only use the cp command to copy from a number of configs in a folder to the one loaded by the program, tint2 and xfce4-terminal in this case, so there are already backups.
edit: Also maybe interesting, https://forums.bunsenlabs.org/viewtopic.php?id=5075
Looks good. I'll have a look at the github for tips and hints. I wanted a script where I chose each config so I can mix and match, say sometimes I want a dark terminal and tint2 but light gtk and ob themes on rainy days but everything light on sunny days,
lbdesign, I do it like this:
cp -f "$ob_rc" "$ob_rc"."$me" # priceless piece of information: https://superuser.com/a/508143 xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "$CURRENT_THEME" "$ob_rc"
xmlstarlet is a more suitable tool for editing XML files.
I understand nothing of that. Not a coder here. Isn't $ob_rc a variable? And where do I set that?
Last edited by lbdesign (2021-05-17 08:48:34)
Offline
brontosaurusrex wrote:edit: Also maybe interesting, https://forums.bunsenlabs.org/viewtopic.php?id=5075
Looks good. I'll have a look at the github for tips and hints. I wanted a script where I chose each config so I can mix and match, say sometimes I want a dark terminal and tint2 but light gtk and ob themes on rainy days but everything light on sunny days,
I see, my lil script works similar to it's influencer (blob), storing everything (whatever is preconfigured in script) in slots. What I find interesting is that it can compare active vs stored configs with some diff-ing around. That same diff will also prevent storing exactly the same slot that already exist. p.s. Also keep in mind that it is not compatible with bunsen paths, targeting plain Debian openbox.
Offline
@lbdesign it looks to me as if the existing BLOB script shipped with BunsenLabs might do what you want.
Menu > BL Utilities > BLOB Themes Manager
Set up your themes, settings etc the way you want it for eg RainyDay, then use BLOB to save the settings with a name you choose. Do the same for SunnyDay etc... You can then use BLOB to restore whichever setup you want.
BLOB is meant to be usable that way, so if it doesn't work for you we'd be interested to know!
...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
I don't use bunsenlabs anymore, but have a minimal debian netinstall with openbox. Also I want the script to be simple and usable on whatever distro I use. It's a highly personal project meant to be used by me only
Offline
^OK understood. It sounds like a nice project.
After spending some time on BLOB (with @damo) I think it's safe to say it won't necessarily turn out to be so simple!
But the code might give you some ideas - it's in /usr/bin/bl-obthemes (~2000 lines atm), or here: https://github.com/BunsenLabs/bunsen-ut … l-obthemes
Maybe @brontosaurusrex's script will be a better base...
...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
I understand nothing of that. Not a coder here. Isn't $ob_rc a variable? And where do I set that?
Oh, I'm sorry.
ob_rc is a variable that contains the path to your openbox rc.xml.
The first line is just making a backup; let's remove it to make it a little clearer, hopefully.
Let's assume you want to change the current theme to Adwaita:
theme="Adwaita"
ob_rc="$HOME/.config/openbox/rc.xml"
# priceless piece of information: https://superuser.com/a/508143
xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "$theme" "$ob_rc"
XML is best edited with XML tools, of which there are plenty.
openbox generates XML with newlines between nodes, and always has; it is probably pretty safe to edit it with sed, which is a line editor.
But XML per se does not require newlines at all, and in a case like that sed would probably fail.
Offline
Yeah. I can see I stand at the edge of a rabbit hole I might just stick with lxappearance for gtk and icon stuff since some programs, like gpick, doesn't obey the changes to settings.ini and .gtkrc files. All I wanted to do was make life a little easier
I installed xmlstarlet and got it working and it's brilliant. Going to make working with xml files so much easier in the future. Thanks for the tip.
# switch openbox theme
clear
echo -e "Choose openbox theme \n"
PS3="Type a number or 'q' to quit: "
fileList=$(find ~/.themes -type d -name "openbox-3" | cut -d "/" -f5)
ob_rc="$HOME/.config/openbox/rc.xml"
select fileName in $fileList; do
if [ -n "$fileName" ]; then
# priceless piece of information: https://superuser.com/a/508143
xmlstarlet ed -L -N o="http://openbox.org/3.4/rc" -u '/o:openbox_config/o:theme/o:name' -v "$fileName" "$ob_rc"
openbox --reconfigure
fi
break
done
Offline