aboutsummaryrefslogtreecommitdiff
path: root/util/update_keys.lua
diff options
context:
space:
mode:
authorPavel Labath <pavelo@centrum.sk>2011-08-16 18:09:06 (GMT)
committerPavel Labath <pavelo@centrum.sk>2013-02-18 21:04:27 (GMT)
commitc0ff6ce3cb262f0dc24c3a79b2c40f36fdf1639b (patch)
treed3af46ae05e036ae125336edb96c7891536c0011 /util/update_keys.lua
parent5902ade8a996f7dcf085b4f4fc2d1425bce809f6 (diff)
downloadfluxbox_pavel-c0ff6ce3cb262f0dc24c3a79b2c40f36fdf1639b.zip
fluxbox_pavel-c0ff6ce3cb262f0dc24c3a79b2c40f36fdf1639b.tar.bz2
fluxbox-update_configs: automatically update keys file
Diffstat (limited to 'util/update_keys.lua')
-rw-r--r--util/update_keys.lua48
1 files changed, 48 insertions, 0 deletions
diff --git a/util/update_keys.lua b/util/update_keys.lua
new file mode 100644
index 0000000..5edab2c
--- /dev/null
+++ b/util/update_keys.lua
@@ -0,0 +1,48 @@
1local file = ...;
2local keymodes = {};
3local failed = false;
4
5local function process_line(line)
6 if string.match(line, '^%s*$') ~= nil then
7 return line;
8 end;
9 local comment = string.match(line, '^%s*[#!](.*)$');
10 if comment ~= nil then
11 return '--' .. comment;
12 end;
13
14 local mode, key, cmd = string.match(line, '^%s*(%a%w*):%s*([^:]-)%s*:(.*)$');
15 if key == nil then
16 key, cmd = string.match(line, '^%s*([^:]*):(.*)$');
17 end;
18
19 if mode == nil or mode == 'default' then
20 mode = 'default_keymode';
21 else
22 keymodes[mode] = true;
23 end;
24
25 if key ~= nil then
26 return string.format('%s[%q] = %q', mode, key, cmd);
27 else
28 failed = true;
29 return '-- FBCV16 ' .. line;
30 end;
31end;
32
33file = string.gsub(file, '[^\n]*', process_line);
34
35local decls = '';
36for k, v in pairs(keymodes) do
37 decls = decls .. k .. ' = newKeyMode();\n';
38end;
39
40if failed == true then
41 decls = [[
42--fluxbox-update_configs could not convert some of the lines into the new format.
43--These lines are marked with FBCV16 and you will have to convert them yourself.
44
45]] .. decls;
46end;
47
48return decls .. '\n' .. file;