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
1 Like

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

1 Like