You are not logged in.

#1 2012-04-03 16:50:37

Wieke
Member
Registered: 2012-02-07
Posts: 8

Openbox rc.xml importing other xml files

Hi everyone

I've been trying to get rc.xml to import settings from another file but now I am stuck.

What i've done so far is add the following code to the beginning (second line) of rc.xml. My system is freshly installed so these are the first changes I made to the file.

<!DOCTYPE doc [
<!ENTITY keybindings SYSTEM "keybindings.xml">
]>

Then I added "&keybindings;" on the next line after "<!-- Keybindings for running applications -->". And put the following code in keybindings.xml.

    <keybind key="W-t">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>xterm</name>
        </startupnotify>
        <command>xterm</command>
      </action>
    </keybind>

Dodn't get any errors when I reconfigured openbox, but the keybinding doesn't work. If I add the keybinding to rc.conf intself, it does work. If I understand it correctly (which I probably don't, have next to no experience with xml) it should work, but it doesn't.

Does anybody know why not?

Thanks in advance

Last edited by Wieke (2012-04-04 16:57:22)

Offline

#2 2012-04-03 18:57:16

dodo3773
Member
Registered: 2011-03-17
Posts: 818

Re: Openbox rc.xml importing other xml files

Did you put this in the section:

<keyboard>

</keyboard>

Also, (not sure if this matters) in my rc.xml the <command> is right after <action>. An example:

<keybind key="W-e">
      <action name="Execute">
        <command>kfmclient openProfile filemanagement</command>
        <startupnotify>
          <enabled>yes</enabled>
          <name>Konqueror</name>
        </startupnotify>
      </action>
    </keybind>

I don't see why that would matter since they're both in <keybind> though.

Offline

#3 2012-04-03 19:01:34

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: Openbox rc.xml importing other xml files

I know you can specify multiple menu xml files, but I don't think you can do similar for keybinds.

Offline

#4 2012-04-04 07:48:05

Dustbin
Member
From: The Netherlands
Registered: 2011-12-07
Posts: 124

Re: Openbox rc.xml importing other xml files

dodo3773 wrote:

Did you put this in the section:

<keyboard>

</keyboard>

This is a valid question... Put it in the wrong part of your rc.xml and it will not load...

dodo3773 wrote:

... (not sure if this matters) in my rc.xml the <command> is right after <action>. An example:

<keybind key="W-e">
      <action name="Execute">
        <command>kfmclient openProfile filemanagement</command>
        <startupnotify>
          <enabled>yes</enabled>
          <name>Konqueror</name>
        </startupnotify>
      </action>
    </keybind>

I don't see why that would matter since they're both in <keybind> though.

AFAIK it does matter, because the order of attributes (in this case the <command> and <startupnotify> attributes) is vital to the correct translation of XML (using an XSD or other schema definition)...


If the Matrix was real, it would run on Arch...

Offline

#5 2012-04-04 11:43:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,544
Website

Re: Openbox rc.xml importing other xml files

Use XInclude instead:

<?xml version="1.0"?>
<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">

<!-- Lots of other stuff here -->

<keyboard>
  <xi:include href="keys.xml"/>
</keyboard>

<!-- Some other stuff here -->

Just add the additional xmlns to the opening tag, then use xi:href tags wherever you'd lilke


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2012-04-04 16:50:35

Wieke
Member
Registered: 2012-02-07
Posts: 8

Re: Openbox rc.xml importing other xml files

The location/line of where I imported was correct, as was the code being imported. The problem was my method for importing, which for some reason did not work. However XInclude, which Trilby suggested, did work.

Thanks everyone, problem solved. This will make synchronizing keybinding between systems a lot easier.

EDIT:

Stumbled upon another problem. I added another keybinding, basically copied the previous one and changed it a bit. And now it cries foul when I reconfigure openbox, throwing a syntax error at me. Weird thing is either keybinding works as long as it is the only keybinding in the imported file.

keybindings.xml is now:

    <keybind key="W-t">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>xterm</name>
        </startupnotify>
        <command>xterm</command>
      </action>
    </keybind>
    <keybind key="W-c">
      <action name="Execute">
        <startupnotify>
          <enabled>true</enabled>
          <name>chromium</name>
        </startupnotify>
        <command>chromium</command>
      </action>
    </keybind>

As I said, on their own either keybinding works but if I put them together in the file I get a syntax error.

Last edited by Wieke (2012-04-04 17:02:57)

Offline

#7 2012-04-05 00:40:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,544
Website

Re: Openbox rc.xml importing other xml files

Doh!  Sorry, my xml-foo isn't quite as good as I thought.  I did replicate your issue, then I realized what was wrong.

The XInclude tag apparently has to be able to find a single root element of the included file.  Good news is I just tested a modification to the above example and it works.  Just put the <keyboard> ... </keyboard> tags in the included file so there is a single root element in that file and it will work.  Also, of course, take the <keyboard> tag out of the main rc.xml file.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2012-04-05 10:10:37

Wieke
Member
Registered: 2012-02-07
Posts: 8

Re: Openbox rc.xml importing other xml files

Trilby wrote:

Good news is I just tested a modification to the above example and it works.  Just put the <keyboard> ... </keyboard> tags in the included file so there is a single root element in that file and it will work.  Also, of course, take the <keyboard> tag out of the main rc.xml file.

Ah damn, I was hoping I could save my customized keybindings in a separate file while keeping the standard ones in rc.xml. Oh well, at least splitting up rc.xml would make it a bit easier to modify.

Offline

#9 2012-04-05 12:01:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,544
Website

Re: Openbox rc.xml importing other xml files

Hmm.  Well, you could have have a keys.xml, default_keys.xml, and custom_keys.xml, then just use the following script whenever one of them changes

#!/bin/bash

echo "<keyboard>" > keys.xml
cat default_keys.xml custom_keys.xml >> keys.xml
echo "</keyboard>" >> keys.xml

Just include keys.xml in the rc.xml using the previous XInclude line.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB