You are not logged in.
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
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
I know you can specify multiple menu xml files, but I don't think you can do similar for keybinds.
Offline
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...
... (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
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
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
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
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
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