]> git.mdlowis.com Git - proto/labwc.git/commitdiff
rcxml: load default keybinds on <keyboard><default />
authorJohan Malm <jgm323@gmail.com>
Sun, 22 Aug 2021 18:09:31 +0000 (19:09 +0100)
committerJohan Malm <jgm323@gmail.com>
Sun, 22 Aug 2021 18:09:31 +0000 (19:09 +0100)
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

README.md
docs/labwc-config.5.scd
docs/rc.xml
docs/rc.xml.all [new file with mode: 0644]
src/config/rcxml.c

index c6fc7885bef558ebd8a6b0caadb9103a966d1901..b46c449c84822ccc94b3488bb4852cb9e1b97d44 100644 (file)
--- a/README.md
+++ b/README.md
@@ -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
index 494c58e073f1e2d15f8ac93e92142f00f4626447..a343875c6efd7ba90fad8087216b761ae07eef09 100644 (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
index 7ec6c6d7555aa8aa3a9562bba6be6e90a478ee06..9f4bff4f28f4376e31b6f1f215d619cb861adde3 100644 (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>
diff --git a/docs/rc.xml.all b/docs/rc.xml.all
new file mode 100644 (file)
index 0000000..48fcf7a
--- /dev/null
@@ -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>
index 7fdc7d18cbd4d17c69bf81a3ba6f1be74b4133c6..2371482c6a41a676fc66ac1e98e13d78ee409aca 100644 (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;
        }