rcxml: load default keybinds on <keyboard><default />

This is an addition to the openbox specification and provides a way to
keep config files simpler whilst allowing user-specific keybinds.

docs/rc.xml shows a simple config file with <default />
docs/rc.xml.full shows the full config
This commit is contained in:
Johan Malm 2021-08-22 19:09:31 +01:00
parent 93244cfbe1
commit b7573c8d36
5 changed files with 105 additions and 42 deletions

View file

@ -76,6 +76,8 @@ Labwc uses the files listed below for configuration and theming.
| [environment] | ~/.config/labwc/ | [labwc-environment(5)]
| [themerc] | ~/.local/share/themes/\<theme-name\>/openbox-3/ | [labwc-theme(5)]
The example [rc.xml] has been kept simple. For all options and default values, see [rc.xml.full]
Configuration and theme files are re-loaded on receiving SIGHUP (e.g. `killall -SIGHUP labwc`)
For keyboard settings, see [environment] and [xkeyboard-config(7)]
@ -140,6 +142,7 @@ High-level summary of items which are not inteded to be implemented:
[openbox-3.4]: https://github.com/danakj/openbox
[rc.xml]: docs/rc.xml
[rc.xml.full]: docs/rc.xml.full
[menu.xml]: docs/menu.xml
[autostart]: docs/autostart
[environment]: docs/environment

View file

@ -25,8 +25,8 @@ Configuration must be wrapped in a <labwc_config> root-node.
Default is server.
*<core><gap>*
The gap in pixels between views and output edges when using movement
actions, for example MoveToEdge. Default is 0.
The distance in pixels between views and output edges when using
movement actions, for example MoveToEdge. Default is 0.
# FOCUS
@ -71,22 +71,22 @@ Configuration must be wrapped in a <labwc_config> root-node.
*<keyboard><keybind key=""><action name="">*
Keybind action. See labwc-action(5)
Default key-binds if no rc.xml is found:
*<keyboard><default />*
Load the default keybinds listed below. This is an addition to the
openbox specification and provides a way to keep config files simpler
whilst allowing your specific keybinds.
Note that if no rc.xml is found, or if no <keyboard><keybind> entries
exist, the same default keybinds will be loaded even if the <default />
element is not provided.
```
<keyboard>
<keybind key="A-Escape">
<action name="Exit"/>
</keybind>
<keybind key="A-Tab">
<action name="NextWindow"/>
</keybind>
<keybind key="A-F3">
<action name="Execute">
<command>bemenu-run</command>
</action>
</keybind>
<keyboard>
A-Tab - next window
A-Escape - exit
W-Return - alacritty
A-F3 - run bemenu
A-F4 - close window
W-a - toggle maximize
A-<arrow> - move window to edge
```
# SEE ALSO

View file

@ -8,35 +8,14 @@
<theme>
<name></name>
<cornerRadius>8</cornerRadius>
<font><name>Sans</name><size>12</size></font>
<font><name>sans</name><size>10</size></font>
</theme>
<focus>
<followMouse>no</followMouse>
<raiseOnFocus>no</raiseOnFocus>
</focus>
<!--
Keybind actions are specified in more detail in labwc-actions(5)
The following keybind modifiers are supported:
W - window/super/logo
A - alt
C - ctrl
S - shift
-->
<keyboard>
<keybind key="A-Escape"><action name="Exit" /></keybind>
<keybind key="A-Tab"><action name="NextWindow" /></keybind>
<keybind key="A-Return"><action name="Execute"><command>sakura</command></action></keybind>
<keybind key="A-F3"><action name="Execute"><command>bemenu-run</command></action></keybind>
<keybind key="A-F4"><action name="Close" /></keybind>
<keybind key="W-a"><action name="ToggleMaximize" /></keybind>
<keybind key="A-Left"><action name="MoveToEdge"><direction>left</direction></action></keybind>
<keybind key="A-Right"><action name="MoveToEdge"><direction>right</direction></action></keybind>
<keybind key="A-Up"><action name="MoveToEdge"><direction>up</direction></action></keybind>
<keybind key="A-Down"><action name="MoveToEdge"><direction>down</direction></action></keybind>
<default />
<keybind key="A-Return">
<action name="Execute"><command>sakura</command></action>
</keybind>
</keyboard>
</labwc_config>

74
docs/rc.xml.all Normal file
View file

@ -0,0 +1,74 @@
<?xml version="1.0"?>
<!-- This file contains all supported config elements and attributes -->
<labwc_config>
<core>
<decoration>server</decoration>
<gap>10</gap>
</core>
<theme>
<name></name>
<cornerRadius>8</cornerRadius>
<!-- Font can be defined without attributues to set all places the same -->
<font place="ActiveWindow"><name>sans</name><size>10</size></font>
<font place="MenuItem"><name>sans</name><size>10</size></font>
</theme>
<focus>
<followMouse>no</followMouse>
<raiseOnFocus>no</raiseOnFocus>
</focus>
<!--
Keybind actions are specified in more detail in labwc-actions(5)
The following keybind modifiers are supported:
W - window/super/logo
A - alt
C - ctrl
S - shift
-->
<keyboard>
<!--
The element <default /> to load the default keybind and thus avoid
repeating all the definitions below.
-->
<keybind key="A-Escape">
<action name="Exit" />
</keybind>
<keybind key="A-Tab">
<action name="NextWindow" />
</keybind>
<keybind key="A-Return">
<action name="Execute"><command>alacritty</command></action>
</keybind>
<keybind key="A-F3">
<action name="Execute"><command>bemenu-run</command></action>
</keybind>
<keybind key="A-F4">
<action name="Close" />
</keybind>
<keybind key="W-a">
<action name="ToggleMaximize" />
</keybind>
<keybind key="A-Left">
<action name="MoveToEdge"><direction>left</direction></action>
</keybind>
<keybind key="A-Right">
<action name="MoveToEdge"><direction>right</direction></action>
</keybind>
<keybind key="A-Up">
<action name="MoveToEdge"><direction>up</direction></action>
</keybind>
<keybind key="A-Down">
<action name="MoveToEdge"><direction>down</direction></action>
</keybind>
</keyboard>
</labwc_config>

View file

@ -152,6 +152,13 @@ entry(xmlNode *node, char *nodename, char *content)
printf("%s: %s\n", nodename, content);
}
/* handle nodes without content, e.g. <keyboard><default /> */
if (!strcmp(nodename, "default.keyboard")) {
load_default_key_bindings();
return;
}
/* handle the rest */
if (!content) {
return;
}