Fix-openbox-rc-xml: Update rc.xml and keep your customizations

Hi guys

This is a simple script to insert my customizations in rc.xml after I execute a

mb-reset obrcxml

So this is how it works:

I have two files openbox-applications.xml and openbox-keyboard.xml.
Each file contains my customizations for the applications and keyboard sections of rc.xml
The scripts are saved in ~/.local/scripts

openbox-applications.xml


    <application class="Thunderbird">
      <desktop>4</desktop>
      <maximized>yes</maximized>
      <focus>yes</focus>
    </application>
    <application class="ViberPC">
      <desktop>4</desktop>
      <focus>yes</focus>
      <maximized>yes</maximized>
    </application>

openbox-keyboard.xml

    <keybind key="A-W-l">
      <action name="Execute">
        <command>libreoffice</command>
      </action>
    </keybind>
    <keybind key="W-q">
      <action name="Execute">
        <command>whereismyip</command>
      </action>
    </keybind>
    <keybind key="W-p">
      <action name="Execute">
        <command>rofi -modi "clipboard:greenclip print" -show clipboard -run-command '{cmd}'</command>
      </action>
    </keybind>

So, after I execute mb-reset obrcxml, I also run

fix-openbox-rc-xml

and I end up with all the recent changes plus my customizations…

Hope someone finds this useful

fix-openbox-rc-xml

#!/bin/bash
[ -s ~/.local/scripts/openbox-applications.xml ] && sed '/<.applications>/i MARKER' ~/.config/openbox/rc.xml | sed -e '/MARKER/r ~/.local/scripts/openbox-applications.xml' -e '/MARKER/d' > ~/.config/openbox/rc.xml.new && mv ~/.config/openbox/rc.xml.new ~/.config/openbox/rc.xml

[ -s ~/.local/scripts/openbox-keyboard.xml ] && sed '/<.keyboard>/i MARKER' ~/.config/openbox/rc.xml | sed -e '/MARKER/r ~/.local/scripts/openbox-keyboard.xml' -e '/MARKER/d' > ~/.config/openbox/rc.xml.new && mv ~/.config/openbox/rc.xml.new ~/.config/openbox/rc.xml
3 Likes

Thanks for sharing :slight_smile:

I am currently working on some improvements for the mb-reset script, and I hope it will be easier with the next update :slight_smile:
Especially with very important files such as rc.xml, autostart and .bashrc

3 Likes

Your idea is very useeeful! This is what I am also looking for!

Could you help me with the addition of preserving my .bashrc-personal and .bash_alias modifications, please? What should I have to add to your fix-openbox-rc-xml script?

Hi @lobaluna

I understand that with the latest updates of mb-reset, this script is not needed anymore.

Having said that, I am expanding the script, to make it more general, just for those of us who prefer to do things manually, and I will probably release a gist, so hang in there.

S.

So, here it is…

Download it, and run

fix-openbox-rc-xml -h

then

fix-openbox-rc-xml -lh

Any problems, suggestions, etc. are welcomed

Thanks, sng!
Also good to know the history of the idea.

1 Like