keyd icon indicating copy to clipboard operation
keyd copied to clipboard

[PATCH] keyd-application-mapper: allow empty sections to fall through to next section

Open daniel-alegria3 opened this issue 6 months ago • 0 comments

My use case is, I use the application mapper to change binds when playing games. I basically use the same rebinds every time, so I would rather avoid repetition in my config file. For example:

# ~/.config/keyd/app.conf

[steam-app-*]
[pmkm2]
[bloodthief]
z = z    # used to be overload(z, ...)
x = x    # used to be overload(x, ...)
c = c    # used to be overload(c, ...)

[steam-app-*|undertale]
w = up
a = left
s = down
d = right

I think this or another implementation that does the same thing should be in upstream.

Here is the patch:

From 69342bd935837f663cb760f0e4324b3b1efaa3f7 Mon Sep 17 00:00:00 2001
From: Daniel Alegria Sallo <[email protected]>
Date: Tue, 10 Jun 2025 22:50:44 -0500
Subject: [PATCH] keyd-application-mapper: allow empty sections to fall through
 to next section

---
 scripts/keyd-application-mapper | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/keyd-application-mapper b/scripts/keyd-application-mapper
index 91a365b..9ffbeaf 100755
--- a/scripts/keyd-application-mapper
+++ b/scripts/keyd-application-mapper
@@ -78,7 +78,9 @@ def parse_config(path):
                 cls = a[0]
                 title = a[1]
 
-            bindings = []
+            if len(config) == 0 or len(bindings) > 0:
+                bindings = []
+
             config.append((cls, title, bindings))
         elif line == '':
             continue
-- 
2.49.0

Please let me know if I should make a pull request instead.

daniel-alegria3 avatar Jun 11 '25 04:06 daniel-alegria3